Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-pc-cloud
This commit is contained in:
commit
b4452049d6
5 files changed
+108
-41
No files matched your search
@@ -1,53 +1,53 @@
|
||||
<template>
|
||||
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible"
|
||||
<el-dialog :title="readonly ? '详情' : (form.id ? '编辑' : '新增')" v-model="visible"
|
||||
:close-on-click-modal="false" draggable>
|
||||
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入标题"/>
|
||||
<el-input v-model="form.title" placeholder="请输入标题" :disabled="readonly"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="工单紧急层度" prop="urgency">
|
||||
<el-select v-model="form.urgency" placeholder="请选择工单紧急层度">
|
||||
<el-select v-model="form.urgency" placeholder="请选择工单紧急层度" :disabled="readonly">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item, index) in maintenance_urgency" :key="index"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="图片" prop="picUrl">
|
||||
<upload-img v-model="form.picUrl"></upload-img>
|
||||
<upload-img v-model="form.picUrl" :disabled="readonly"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="描述" prop="description">
|
||||
<editor v-if="visible" v-model:get-html="form.description" placeholder="请输入描述"></editor>
|
||||
<editor v-if="visible" v-model:get-html="form.description" placeholder="请输入描述" :readonly="readonly"></editor>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="发现日期" prop="dateFound">
|
||||
<el-date-picker type="date" placeholder="请选择发现日期" v-model="form.dateFound" :value-format="dateStr"></el-date-picker>
|
||||
<el-date-picker type="date" placeholder="请选择发现日期" v-model="form.dateFound" :value-format="dateStr" :disabled="readonly"></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="发现地点" prop="location">
|
||||
<el-input v-model="form.location" placeholder="请输入发现地点"/>
|
||||
<el-input v-model="form.location" placeholder="请输入发现地点" :disabled="readonly"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input v-model="form.sort" placeholder="请输入排序"/>
|
||||
<el-input v-model="form.sort" placeholder="请输入排序" :disabled="readonly"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="form.status" placeholder="请选择状态">
|
||||
<el-select v-model="form.status" placeholder="请选择状态" :disabled="readonly">
|
||||
<el-option :value="item.value" :label="item.label" v-for="(item, index) in maintenance_status" :key="index"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -57,8 +57,8 @@
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
<el-button @click="visible = false">{{ readonly ? '关闭' : '取消' }}</el-button>
|
||||
<el-button v-if="!readonly" type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
@@ -75,6 +75,7 @@ const emit = defineEmits(['refresh']);
|
||||
const dataFormRef = ref();
|
||||
const visible = ref(false)
|
||||
const loading = ref(false)
|
||||
const readonly = ref(false)
|
||||
// 定义字典
|
||||
const { maintenance_urgency,maintenance_status } = useDict('maintenance_urgency','maintenance_status')
|
||||
|
||||
@@ -101,10 +102,10 @@ const dataRules = ref({
|
||||
})
|
||||
|
||||
// 打开弹窗
|
||||
const openDialog = (id: string) => {
|
||||
const openDialog = (id: string, isReadonly = false) => {
|
||||
visible.value = true
|
||||
form.id = ''
|
||||
|
||||
readonly.value = isReadonly
|
||||
// 重置表单数据
|
||||
nextTick(() => {
|
||||
dataFormRef.value?.resetFields();
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
<el-table-column type="selection" width="40" align="center" />
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="title" label="标题" show-overflow-tooltip/>
|
||||
<el-table-column prop="sort" label="排序" show-overflow-tooltip/>
|
||||
<el-table-column prop="status" label="状态" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<dict-tag :options="maintenance_status" :value="scope.row.status"></dict-tag>
|
||||
@@ -49,12 +48,14 @@
|
||||
<dict-tag :options="maintenance_urgency" :value="scope.row.urgency"></dict-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="userId" label="上报人" show-overflow-tooltip/>
|
||||
<el-table-column label="操作" width="150">
|
||||
<el-table-column prop="createBy" label="上报人" show-overflow-tooltip/>
|
||||
<el-table-column prop="sort" label="排序" show-overflow-tooltip/>
|
||||
<el-table-column label="操作" width="200">
|
||||
<template #default="scope">
|
||||
<el-button icon="edit-pen" text type="primary" v-auth="'integrated_maintenanceOrder_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||
<el-button icon="view" text type="primary" v-auth="'integrated_maintenanceOrder_edit'"
|
||||
@click="formDialogRef.openDialog(scope.row.id, true)">详情</el-button>
|
||||
<el-button icon="delete" text type="primary" v-auth="'integrated_maintenanceOrder_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||
<el-button icon="Check" text type="success" v-if="scope.row.status != 1" @click="handleProcessed(scope.row)">已处理</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -69,7 +70,7 @@
|
||||
|
||||
<script setup lang="ts" name="systemMaintenanceOrder">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs } from "/@/api/integrated/maintenanceOrder";
|
||||
import { fetchList, delObjs, putObj } from "/@/api/integrated/maintenanceOrder";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
|
||||
@@ -138,4 +139,20 @@ const handleDelete = async (ids: string[]) => {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 添加已处理操作
|
||||
const handleProcessed = async (row: any) => {
|
||||
try {
|
||||
await useMessageBox().confirm('确定将该工单标记为已处理吗?');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await putObj({ ...row, status: 1 });
|
||||
useMessage().success('已处理');
|
||||
getDataList();
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
<script setup lang="ts" name="systemShopCategory">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||
import { fetchList, delObjs, tree as fetchTree } from "/@/api/supermarket/shopCategory";
|
||||
import { fetchList, delObjs, tree as fetchTree, putObj } from "/@/api/supermarket/shopCategory";
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||
import { useDict } from '/@/hooks/dict';
|
||||
import { ref, reactive, onMounted, defineExpose } from 'vue';
|
||||
|
||||
@@ -33,7 +33,11 @@
|
||||
<upload-img v-model:imageUrl="form.picUrl"></upload-img>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="商品详情" prop="description">
|
||||
<editor v-if="visible" v-model:get-html="form.description" placeholder="请输入商品详情"></editor>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mb20">
|
||||
<el-form-item label="库存" prop="stock">
|
||||
<el-input-number :min="0" :max="1000" v-model="form.stock" placeholder="请输入库存"></el-input-number>
|
||||
@@ -44,11 +48,6 @@
|
||||
<el-input-number :min="1" :max="1000" v-model="form.limitNum" placeholder="请输入单人限购数量"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24" class="mb20">
|
||||
<el-form-item label="商品详情" prop="description">
|
||||
<editor v-if="visible" v-model:get-html="form.description" placeholder="请输入商品详情"></editor>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
@@ -110,12 +109,6 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="purchasePrice" width="100">
|
||||
<template #header>进价</template>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.purchasePrice" placeholder="进价/单位分" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="promotionPrice" width="140">
|
||||
<template #header>促销价</template>
|
||||
<template #default="scope">
|
||||
@@ -137,9 +130,9 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="attribute" width="120">
|
||||
<template #header>SKU属性</template>
|
||||
<template #header>口味</template>
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.attribute" placeholder="SKU属性" />
|
||||
<el-input v-model="scope.row.attribute" placeholder="口味" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80">
|
||||
@@ -303,7 +296,8 @@ const onSubmit = async () => {
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
const merchantIds = selectedMerchants.value.map(m => m.id);
|
||||
// merchantIds 逗号分隔字符串
|
||||
const merchantIds = selectedMerchants.value.map(m => m.id).join(',');
|
||||
const submitForm = {
|
||||
...form,
|
||||
categoryId: Array.isArray(form.categoryId) ? form.categoryId.slice(-1)[0] : form.categoryId,
|
||||
@@ -332,6 +326,25 @@ const getshopSpuData = (id: string) => {
|
||||
if (!form.skuList || form.skuList.length === 0) {
|
||||
addSku();
|
||||
}
|
||||
// 处理 categoryId 回显为数组
|
||||
if (res.data.categoryId && categoryOptions.value.length) {
|
||||
form.categoryId = findCategoryPath(categoryOptions.value, res.data.categoryId);
|
||||
}
|
||||
// 处理 merchantIds 回显
|
||||
if (res.data.merchantIds) {
|
||||
const idsArr = typeof res.data.merchantIds === 'string' ? res.data.merchantIds.split(',').filter(Boolean) : [];
|
||||
selectedMerchantIds.value = idsArr;
|
||||
if (merchantList.value.length) {
|
||||
selectedMerchants.value = merchantList.value.filter(m => idsArr.includes(String(m.id)));
|
||||
} else {
|
||||
fetchMerchantList().then(() => {
|
||||
selectedMerchants.value = merchantList.value.filter(m => idsArr.includes(String(m.id)));
|
||||
});
|
||||
}
|
||||
} else {
|
||||
selectedMerchants.value = [];
|
||||
selectedMerchantIds.value = [];
|
||||
}
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
@@ -343,9 +356,7 @@ function addSku() {
|
||||
spec: '',
|
||||
unit: '',
|
||||
status: 0,
|
||||
purchasePrice: '',
|
||||
retailPrice: '',
|
||||
promotionPrice: '',
|
||||
promotionPrice: 0,
|
||||
stock: '',
|
||||
attribute: ''
|
||||
});
|
||||
@@ -447,6 +458,19 @@ const removeMerchant = (idx: number) => {
|
||||
|
||||
// 打开弹窗时自动加载商户
|
||||
watch(showMerchantDialog, (val) => { if (val) fetchMerchantList(); });
|
||||
|
||||
// 工具函数:根据分类id查找路径
|
||||
function findCategoryPath(options, targetId, path = []) {
|
||||
for (const item of options) {
|
||||
const newPath = path.concat(item.id);
|
||||
if (item.id === targetId) return newPath;
|
||||
if (item.children) {
|
||||
const childPath = findCategoryPath(item.children, targetId, newPath);
|
||||
if (childPath.length) return childPath;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -37,8 +37,11 @@
|
||||
<el-table-column type="index" label="#" width="40" />
|
||||
<el-table-column prop="productCode" label="货号" show-overflow-tooltip/>
|
||||
<el-table-column prop="productName" label="商品名称" show-overflow-tooltip/>
|
||||
<el-table-column prop="description" label="商品详情" show-overflow-tooltip/>
|
||||
<el-table-column prop="categoryId" label="商品分类" show-overflow-tooltip/>
|
||||
<el-table-column prop="categoryId" label="商品分类" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ findCategoryPath(categoryOptions, scope.row.categoryId).join(' / ') }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="picUrl" label="商品封面图" show-overflow-tooltip/>
|
||||
<el-table-column prop="sort" label="排序字段" show-overflow-tooltip/>
|
||||
<el-table-column prop="status" label="商品状态" show-overflow-tooltip>
|
||||
@@ -68,9 +71,11 @@
|
||||
|
||||
<script setup lang="ts" name="systemShopSpu">
|
||||
import { BasicTableProps, useTable } from "/src/hooks/table";
|
||||
import { fetchList, delObjs } from "/src/api/supermarket/shopSpu";
|
||||
import { fetchList, delObjs, putObj } from "/src/api/supermarket/shopSpu";
|
||||
import { useMessage, useMessageBox } from "/src/hooks/message";
|
||||
import { useDict } from '/src/hooks/dict';
|
||||
import { tree as fetchCategoryTree } from '/src/api/supermarket/shopCategory';
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
// 引入组件
|
||||
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||
@@ -101,6 +106,26 @@ const {
|
||||
tableStyle
|
||||
} = useTable(state)
|
||||
|
||||
// 分类树数据
|
||||
const categoryOptions = ref<any[]>([]);
|
||||
onMounted(async () => {
|
||||
const res = await fetchCategoryTree();
|
||||
categoryOptions.value = res.data || [];
|
||||
});
|
||||
|
||||
// 递归查找分类路径
|
||||
function findCategoryPath(options: any[], id: string | number, path: string[] = []): string[] {
|
||||
for (const item of options) {
|
||||
const newPath = [...path, item.name];
|
||||
if (item.id == id) return newPath;
|
||||
if (item.children) {
|
||||
const result = findCategoryPath(item.children, id, newPath);
|
||||
if (result.length) return result;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
|
||||
Reference in new issue
Block a user