| | |
| | | > |
| | | <template #default="{ node, data }"> |
| | | <div class="custom-tree-node"> |
| | | <span>{{ node.label }}</span> |
| | | <span class="tree-node-content"> |
| | | <el-icon class="orange-icon"> |
| | | <component :is="data.children && data.children.length > 0 |
| | | ? node.expanded ? 'FolderOpened' : 'Folder' : 'Tickets'" /> |
| | | </el-icon> |
| | | {{ data.label }} |
| | | </span> |
| | | <div> |
| | | <el-button |
| | | type="primary" |
| | |
| | | > |
| | | 编辑 |
| | | </el-button> |
| | | <el-button type="primary" link @click="openProDia('add', data)"> |
| | | <el-button type="primary" link @click="openProDia('add', data)" :disabled="node.level >= 3"> |
| | | 添加产品 |
| | | </el-button> |
| | | <el-button |
| | |
| | | </el-button> |
| | | </div> |
| | | <PIMTable |
| | | rowKey="id" |
| | | :column="tableColumn" |
| | | :tableData="tableData" |
| | | :page="page" |
| | | :isSelection="true" |
| | | :handleSelectionChange="handleSelectionChange" |
| | | @selection-change="handleSelectionChange" |
| | | :tableLoading="tableLoading" |
| | | @pagination="pagination" |
| | | :total="total" |
| | | ></PIMTable> |
| | | </div> |
| | | <el-dialog v-model="productDia" title="产品" width="400px"> |
| | | <el-dialog v-model="productDia" title="产品" width="400px" @keydown.enter.prevent> |
| | | <el-form |
| | | :model="form" |
| | | label-width="140px" |
| | |
| | | v-model="form.productName" |
| | | placeholder="请输入产品名称" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | title="规格型号" |
| | | width="400px" |
| | | @close="closeModelDia" |
| | | @keydown.enter.prevent |
| | | > |
| | | <el-form |
| | | :model="modelForm" |
| | |
| | | v-model="modelForm.model" |
| | | placeholder="请输入规格型号" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | v-model="modelForm.unit" |
| | | placeholder="请输入单位" |
| | | clearable |
| | | @keydown.enter.prevent |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-row>--> |
| | | <!-- <el-col :span="24">--> |
| | | <!-- <el-form-item label="绑定机器:" prop="speculativeTradingName">--> |
| | | <!-- <el-select--> |
| | | <!-- v-model="modelForm.speculativeTradingName"--> |
| | | <!-- placeholder="请选择绑定机器"--> |
| | | <!-- multiple--> |
| | | <!-- clearable--> |
| | | <!-- style="width: 100%"--> |
| | | <!-- >--> |
| | | <!-- <el-option label="炒机1" value="炒机1" />--> |
| | | <!-- <el-option label="炒机2" value="炒机2" />--> |
| | | <!-- <el-option label="炒机3" value="炒机3" />--> |
| | | <!-- <el-option label="炒机4" value="炒机4" />--> |
| | | <!-- </el-select>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | <!-- </el-row>--> |
| | | </el-form> |
| | | <template #footer> |
| | | <div class="dialog-footer"> |
| | |
| | | label: "单位", |
| | | prop: "unit", |
| | | }, |
| | | // { |
| | | // label: "绑定机器", |
| | | // prop: "speculativeTradingName", |
| | | // }, |
| | | { |
| | | dataType: "action", |
| | | label: "操作", |
| | |
| | | const tableData = ref([]); |
| | | const tableLoading = ref(false); |
| | | const isShowButton = ref(false); |
| | | const total = ref(0); |
| | | const selectedRows = ref([]); |
| | | const page = reactive({ |
| | | current: 1, |
| | | size: 10, |
| | | total: 0, |
| | | }); |
| | | const data = reactive({ |
| | | form: { |
| | |
| | | modelForm: { |
| | | model: "", |
| | | unit: "", |
| | | speculativeTradingName: [], |
| | | }, |
| | | modelRules: { |
| | | model: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | model: [ |
| | | { required: true, message: "请输入", trigger: "blur" } |
| | | ], |
| | | unit: [{ required: true, message: "请输入", trigger: "blur" }], |
| | | speculativeTradingName: [{ required: true, message: "请选择绑定机器", trigger: "change" }], |
| | | }, |
| | | }); |
| | | const { form, rules, modelForm, modelRules } = toRefs(data); |
| | |
| | | modelOperationType.value = type; |
| | | modelDia.value = true; |
| | | modelForm.value.model = ""; |
| | | modelForm.value.model = ""; |
| | | modelForm.value.unit = ""; |
| | | modelForm.value.speculativeTradingName = []; |
| | | modelForm.value.id = ""; |
| | | if (type === "edit") { |
| | | modelForm.value = { ...data }; |
| | | // 如果后端返回的是字符串,需要转换为数组 |
| | | if (data.speculativeTradingName && typeof data.speculativeTradingName === 'string') { |
| | | modelForm.value.speculativeTradingName = data.speculativeTradingName.split(','); |
| | | } |
| | | } |
| | | }; |
| | | // 提交产品名称修改 |
| | |
| | | proxy.$refs.formRef.resetFields(); |
| | | productDia.value = false; |
| | | }; |
| | | |
| | | // 删除产品 |
| | | const remove = (node, data) => { |
| | | let ids = []; |
| | |
| | | const submitModelForm = () => { |
| | | proxy.$refs.modelFormRef.validate((valid) => { |
| | | if (valid) { |
| | | modelForm.value.productId = currentId.value; |
| | | addOrEditProductModel(modelForm.value).then((res) => { |
| | | // 将选中的机器数组转换为逗号分隔的字符串 |
| | | const submitData = { |
| | | ...modelForm.value, |
| | | productId: currentId.value, |
| | | speculativeTradingName: modelForm.value.speculativeTradingName.join(',') |
| | | }; |
| | | addOrEditProductModel(submitData).then((res) => { |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | closeModelDia(); |
| | | getModelList(); |
| | |
| | | }).then((res) => { |
| | | console.log("res", res); |
| | | tableData.value = res.records; |
| | | total.value = res.total; |
| | | page.total = res.total; |
| | | tableLoading.value = false; |
| | | }); |
| | | }; |
| | |
| | | font-size: 14px; |
| | | padding-right: 8px; |
| | | } |
| | | .tree-node-content { |
| | | display: flex; |
| | | align-items: center; /* 垂直居中 */ |
| | | height: 100%; |
| | | } |
| | | .orange-icon { |
| | | color: orange; |
| | | font-size: 18px; |
| | | margin-right: 8px; /* 图标与文字之间加点间距 */ |
| | | } |
| | | </style> |