Prechádzať zdrojové kódy

合作记录,编辑报错。原因:id传错了。

single 9 mesiacov pred
rodič
commit
95f10c01cc

+ 9 - 5
src/pages/srm/components/ProductsDetail.vue

@@ -1,8 +1,8 @@
 <!--
  * @Author: PoJun
  * @Date: 2023-12-22 10:02:47
- * @LastEditors: PoJun
- * @LastEditTime: 2024-01-17 16:24:13
+ * @LastEditors: XuanJi
+ * @LastEditTime: 2024-05-19 16:04:45
  * @Message: 产品目录详情
 -->
 <template>
@@ -18,12 +18,12 @@
             <a-form-model ref="ruleForm" :model="form" :rules="rules">
                 <a-row :gutter="18">
                     <a-col :span="12">
-                        <a-form-model-item label="目录名称" prop="name">
+                        <a-form-model-item :label="directoryType + '名称'" prop="name">
                             <a-input v-model="form.name" placeholder="请输入..." />
                         </a-form-model-item>
                     </a-col>
                     <a-col :span="12">
-                        <a-form-model-item label="目录编码" prop="code">
+                        <a-form-model-item :label="directoryType + '编码'" prop="code">
                             <a-input v-model="form.code" placeholder="请输入..." />
                         </a-form-model-item>
                     </a-col>
@@ -39,7 +39,7 @@
                         </a-form-model-item>
                     </a-col>
                     <a-col :span="24">
-                        <a-form-model-item label="目录图片" prop="image">
+                        <a-form-model-item :label="directoryType + '图片'" prop="image">
                             <upload-img
                                 height="200"
                                 width="200"
@@ -81,6 +81,10 @@ export default {
             type: String,
             default: "add",
         },
+        directoryType: {
+            type: String,
+            default: "目录",
+        },
     },
     data() {
         return {

+ 40 - 5
src/pages/srm/components/WorkingRecords.vue

@@ -1,8 +1,8 @@
 <!--
  * @Author: PoJun
  * @Date: 2023-12-22 15:47:43
- * @LastEditors: PoJun
- * @LastEditTime: 2023-12-22 16:42:49
+ * @LastEditors: XuanJi
+ * @LastEditTime: 2024-05-19 15:49:51
  * @Message: Nothing
 -->
 <template>
@@ -45,6 +45,18 @@
                 <a-form-model-item label="时间" prop="time">
                     <a-date-picker valueFormat="YYYY-MM-DD" v-model="form.time" style="width: 100%" />
                 </a-form-model-item>
+                <a-form-model-item label="关联产品" prop="product">
+                    <a-tree-select
+                        :maxTagCount="4"
+                        v-model="form.product"
+                        style="width: 100%"
+                        :tree-data="treeData"
+                        tree-checkable
+                        search-placeholder="请选择..."
+                        :replaceFields="{ title: 'name', key: 'id', value: 'id' }"
+                        :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
+                    />
+                </a-form-model-item>
             </a-form-model>
         </a-modal>
     </CommonDrawer>
@@ -53,7 +65,13 @@
 <script>
 import CommonDrawer from "@/components/table/CommonDrawer.vue";
 import CommonTable from "@/components/table/CommonTable.vue";
-import { addCooperates, updateCooperates, deleteCooperates, batchDeleteCooperates } from "@/api/index.js";
+import {
+    addCooperates,
+    updateCooperates,
+    deleteCooperates,
+    batchDeleteCooperates,
+    getProductsTreeNoAuth,
+} from "@/api/index.js";
 export default {
     name: "SupplierDetail",
     components: { CommonDrawer, CommonTable },
@@ -76,7 +94,9 @@ export default {
                 time: null,
                 content: "",
                 supplierId: this.detailId,
+                product: [],
             },
+            formId: "",
             rules: {
                 time: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
                 content: [{ required: true, message: "必填项不能为空", trigger: ["change", "blur"] }],
@@ -105,6 +125,7 @@ export default {
                 },
             ],
             detaiType: "",
+            treeData: [],
         };
     },
     methods: {
@@ -114,6 +135,8 @@ export default {
             this.showModal = true;
             this.form.content = row?.content;
             this.form.time = row?.time;
+            this.formId = row?.id;
+            this.form.product = row?.product;
         },
         onClose() {
             setTimeout(() => {
@@ -145,8 +168,10 @@ export default {
         hideModal() {
             this.$refs.authForm.validate(isValid => {
                 if (isValid) {
+                    const formData = Object.assign({}, this.form, { id: this.formId });
+                    console.log(formData);
                     const doAjax =
-                        this.detaiType == "new" ? addCooperates(this.form) : updateCooperates(this.form, this.detailId);
+                        this.detaiType == "new" ? addCooperates(this.form) : updateCooperates(formData, this.formId);
                     doAjax.then(() => {
                         this.$refs.recordsTable.refresh();
                         this.showModal = false;
@@ -154,8 +179,18 @@ export default {
                 }
             });
         },
+        async getTreeData() {
+            try {
+                const data = await getProductsTreeNoAuth();
+                this.treeData = data;
+            } catch (error) {
+                console.log(error);
+            }
+        },
+    },
+    created() {
+        this.getTreeData();
     },
-    created() {},
 };
 </script>
 

+ 9 - 6
src/pages/srm/products.vue

@@ -1,15 +1,15 @@
 <!--
  * @Author: PoJun
  * @Date: 2023-12-22 10:01:43
- * @LastEditors: PoJun
- * @LastEditTime: 2024-01-17 17:04:02
+ * @LastEditors: XuanJi
+ * @LastEditTime: 2024-05-19 16:17:09
  * @Message: 产品目录
 -->
 <template>
     <div class="products">
         <div style="margin-bottom: 10px">
             <a-space :size="12">
-                <a-button type="primary" @click="addRow(null)">新增目录</a-button>
+                <a-button type="primary" @click="addRow(null)">新增目录</a-button>
                 <a-button @click="$refs.xTable.setAllTreeExpand(true)">展开所有</a-button>
                 <a-button @click="$refs.xTable.clearTreeExpand()">关闭所有</a-button>
             </a-space>
@@ -42,7 +42,7 @@
                             </a-tooltip>
                             <!-- 暂时来说只让两层 -->
                             <a-tooltip v-if="row.path.length == 2">
-                                <template slot="title">新增子目录</template>
+                                <template slot="title">新增产品</template>
                                 <a-icon type="plus" @click="addRow(row)" :style="{ fontSize: '16px' }" />
                             </a-tooltip>
                         </a-space>
@@ -65,6 +65,7 @@
             :detailTitle="detailTitle"
             @close="closeDetail"
             @confirm="confirmDetail"
+            :directoryType="directoryType"
         />
     </div>
 </template>
@@ -96,8 +97,9 @@ export default {
         addRow(row) {
             this.detailObj = row;
             this.detailType = "add";
-            this.detailTitle = "新增目录";
+            this.detailTitle = row ? "新增产品" : "新增目录";
             this.showDetail = true;
+            this.directoryType = row ? "产品" : "目录";
         },
         deleteRow(row) {
             this.$confirm({
@@ -111,9 +113,10 @@ export default {
         },
         editRow(row) {
             this.detailType = "edit";
-            this.detailTitle = "编辑目录";
+            this.detailTitle = row.parentName ? "编辑产品" : "编辑目录";
             this.detailObj = row;
             this.showDetail = true;
+            this.directoryType = row.parentName ? "产品" : "目录";
         },
         // 关闭详情窗口
         closeDetail() {