Prechádzať zdrojové kódy

解决配件信息bug

hezhanp 9 mesiacov pred
rodič
commit
077f2a0d7f

+ 7 - 0
src/views/salesServiceManagement/components/info.vue

@@ -338,11 +338,18 @@
       </el-col>
     </el-row>
 
+    <headerTitle
+      title="配件信息"
+      style="margin-top: 10px"
+      v-if="form.part == 1 && isPurchaseNeed"
+    ></headerTitle>
     <spareParts
       ref="sparePartsRef"
       :type="type"
       :source="source"
       obtain="仓库"
+      
+  :is-after-sales="true"
       v-if="form.part == 1 && isPurchaseNeed"
     />
     <div class="after_sales_target" v-if="salesShow">

+ 426 - 423
src/views/salesServiceManagement/components/sparePartsList.vue

@@ -253,458 +253,461 @@
 </template>
 
 <script>
-  import {
-    getWarehouseOutStock,
-    getIdWarehouseList
-  } from '@/api/saleManage/saleorder';
-  import AssetsDialog from './AssetsDialog.vue';
-  import { getByCode } from '@/api/system/dictionary-data';
-  import productList from '@/BIZComponents/product-list.vue';
+import {
+  getWarehouseOutStock,
+  getIdWarehouseList
+} from '@/api/saleManage/saleorder';
+import AssetsDialog from './AssetsDialog.vue';
+import { getByCode } from '@/api/system/dictionary-data';
+import productList from '@/BIZComponents/product-list.vue';
 
-  export default {
-    components: {
-      //   applyForSpare,
-      AssetsDialog,
-      productList
+export default {
+  components: {
+    //   applyForSpare,
+    AssetsDialog,
+    productList
+  },
+  props: {
+    type: '',
+    // 数据来源
+    source: {
+      default: '',
+      type: String
     },
-    props: {
-      type: '',
-      // 数据来源
-      source: {
-        default: '',
-        type: String
-      },
-      // 表格权限操作 状态
-      state: {
-        default: '',
-        type: String
-      },
-      detailList: {
-        type: Array,
-        default: () => []
-      },
-      obtain: {
-        type: String,
-        default: '主数据'
-      }
+    // 表格权限操作 状态
+    state: {
+      default: '',
+      type: String
     },
-    data() {
-      return {
-        loading: false,
-        form: {
-          tableList: []
-        },
-        totalPrice: 0,
-        typeIdList: []
-      };
+    detailList: {
+      type: Array,
+      default: () => []
     },
-    created() {
-      this.getLevelCode('after_sales_project');
+    obtain: {
+      type: String,
+      default: '主数据'
     },
-    computed: {
-      columnsDetail() {
-        return [
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'typeId',
-            label: '项目',
-            align: 'center',
-            width: 120,
-            slot: 'typeId',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'code',
-            label: '编码',
-            align: 'center',
-            slot: 'code',
-            minWidth: 150,
-            showOverflowTooltip: true
-          },
+    isAfterSales: {
+    type: Boolean,
+    default: false // 默认不是售后服务页面
+  }
+  },
+  data() {
+    return {
+      loading: false,
+      form: {
+        tableList: []
+      },
+      totalPrice: 0,
+      typeIdList: []
+    };
+  },
+  created() {
+    this.getLevelCode('after_sales_project');
+  },
+  computed: {
+    columnsDetail() {
+      return [
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'typeId',
+          label: '项目',
+          align: 'center',
+          width: 120,
+          slot: 'typeId',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'code',
+          label: '编码',
+          align: 'center',
+          slot: 'code',
+          minWidth: 150,
+          showOverflowTooltip: true
+        },
 
-          {
-            prop: 'name',
-            label: '名称',
-            align: 'center',
-            minWidth: 250,
-            slot: 'name',
-            showOverflowTooltip: true,
-            headerSlot: 'headerName'
-          },
-          {
-            prop: 'categoryModel',
-            label: '型号',
-            width: 150,
-            align: 'center',
-            slot: 'categoryModel',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'specification',
-            width: 150,
-            label: '规格',
-            slot: 'specification',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'content',
-            minWidth: 300,
-            slot: 'content',
-            label: '详细内容',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'warehouseId',
-            minWidth: 170,
-            slot: 'warehouseId',
-            label: '仓库',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'warehouseNum',
-            minWidth: 100,
-            label: '库存',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'totalCount',
-            slot: 'totalCount',
-            width: 100,
-            label: '数量',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'measureUnit',
-            width: 120,
-            slot: 'measureUnit',
-            label: '单位',
-            align: 'center',
-            showOverflowTooltip: true
-          },
+        {
+          prop: 'name',
+          label: '名称',
+          align: 'center',
+          minWidth: 250,
+          slot: 'name',
+          showOverflowTooltip: true,
+          headerSlot: 'headerName'
+        },
+        {
+          prop: 'categoryModel',
+          label: '型号',
+          width: 150,
+          align: 'center',
+          slot: 'categoryModel',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'specification',
+          width: 150,
+          label: '规格',
+          slot: 'specification',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'content',
+          minWidth: 300,
+          slot: 'content',
+          label: '详细内容',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'warehouseId',
+          minWidth: 170,
+          slot: 'warehouseId',
+          label: '仓库',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'warehouseNum',
+          minWidth: 100,
+          label: '库存',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'totalCount',
+          slot: 'totalCount',
+          width: 100,
+          label: '数量',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'measureUnit',
+          width: 120,
+          slot: 'measureUnit',
+          label: '单位',
+          align: 'center',
+          showOverflowTooltip: true
+        },
 
-          {
-            prop: 'singlePrice',
-            slot: 'singlePrice',
-            width: 120,
-            label: '单价(元)',
-            align: 'center',
-            showOverflowTooltip: true
-          },
+        {
+          prop: 'singlePrice',
+          slot: 'singlePrice',
+          width: 120,
+          label: '单价(元)',
+          align: 'center',
+          showOverflowTooltip: true
+        },
 
-          {
-            prop: 'settlementPrice',
-            width: 80,
-            label: '合计(元)',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 150,
-            align: 'center',
-            resizable: false,
-            slot: 'action',
-            fixed: 'right',
-            showOverflowTooltip: true,
-            show: this.type != 'view'
-          }
-        ];
-      },
-      // 选择按钮显示
-      chooseShow() {
-        return (scope) => {
-          if (this.source == '配件回收') {
-            return true;
-          }
-          let flag =
-            scope.row.typeId == 2 &&
-            scope.row.isApply != 1 &&
-      (this.type == 'edit' || this.type == 'add'); 
-          return flag;
-        };
-      },
+        {
+          prop: 'settlementPrice',
+          width: 80,
+          label: '合计(元)',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 150,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          fixed: 'right',
+          showOverflowTooltip: true,
+          show: this.type != 'view'
+        }
+      ];
+    },
+    // 选择按钮显示
+    chooseShow() {
+      return (scope) => {
+        if (this.source == '配件回收') {
+          return true;
+        }
+        let flag =
+          scope.row.typeId == 2 &&
+          scope.row.isApply != 1 &&
+          (this.type == 'edit' || this.type == 'add');
+        return flag;
+      };
+    },
 
-      // 添加 按钮显示权限
-      buttonJud() {
-        if (this.source == '派单进来') {
+    // 添加 按钮显示权限
+    buttonJud() {
+      if (this.source == '派单进来') {
+        return true;
+      }
+      let flag = this.type != 'view' && this.source != '报工信息';
+      return flag;
+    },
+    // 方案列表删除权限
+    schemeOperate() {
+      return (row) => {
+        if (this.source == '配件回收') {
           return true;
         }
-        let flag = this.type != 'view' && this.source != '报工信息';
+        let flag =
+          this.type != 'view' && row.isApply != 1 && this.source != '报工信息';
         return flag;
+      };
+    },
+    // 方案表格操作权限
+    schemeTableTool() {
+      return (row) => {
+        let flag = this.type == 'view' || row.isApply == 1;
+        return flag;
+      };
+    },
+    // input输入权限
+    inputOperate() {
+      return (row) => {
+        let flag = this.type == 'view' || row.isApply == 1;
+        return flag;
+      };
+    }
+  },
+  watch: {
+    detailList: {
+      handler(newVal) {
+        this.form.tableList = newVal;
       },
-      // 方案列表删除权限
-      schemeOperate() {
-        return (row) => {
-          if (this.source == '配件回收') {
-            return true;
-          }
-          let flag =
-            this.type != 'view' &&
-            row.isApply != 1 &&
-            this.source != '报工信息';
-          return flag;
-        };
-      },
-      // 方案表格操作权限
-      schemeTableTool() {
-        return (row) => {
-          let flag = this.type == 'view' || row.isApply == 1;
-          return flag;
-        };
-      },
-      // input输入权限
-      inputOperate() {
-        return (row) => {
-          let flag = this.type == 'view' || row.isApply == 1;
-          return flag;
-        };
+      immediate: true
+    }
+  },
+  mounted() {
+    if (this.source == '配件回收') {
+      this.typeIdList = [
+        {
+          label: '零配件',
+          value: '2'
+        }
+      ];
+    }
+    if (this.detailList.length > 0) {
+      this.form.tableList = this.detailList;
+    }
+    if (this.isAfterSales) {
+    this.typeIdList = [{ label: '零配件', value: '2' }];
+  }
+  },
+  methods: {
+    init(row) {},
+async getLevelCode(code) {
+  try {
+    const res = await getByCode(code);
+    if (res.code == 0) {
+      let list = Object.values(res.data).map((el) => {
+        let k = Object.keys(el)[0];
+        let v = Object.values(el)[0];
+        return { label: v, value: k };
+      });
+
+      if (this.isAfterSales) {
+        list = list.filter(item => item.value === '2'); 
       }
-    },
-    watch: {
-      detailList: {
-        handler(newVal) {
-          this.form.tableList = newVal;
-        },
-        immediate: true
+
+      this.typeIdList = list;
+    }
+  } catch (err) {
+    this.$message.error(err.message);
+  }
+},
+    typeIdChange(row, index) {
+      let obj = {
+        typeId: row.typeId,
+        code: '',
+        name: '',
+        categoryModel: '',
+        specification: '',
+        content: '',
+        totalCount: 1,
+        measureUnit: '',
+        singlePrice: '',
+        settlementPrice: ''
+      };
+      let o = this.typeIdList.find((item) => item.value == row.typeId);
+      if (o.value != 2) {
+        obj.name = o.label;
       }
+      this.$set(this.form.tableList, index, obj);
     },
-    mounted() {
-      if (this.source == '配件回收') {
-        this.typeIdList = [
-          {
-            label: '零配件',
-            value: '2'
+    getValidate() {
+      return new Promise((resolve, reject) => {
+        this.$refs.form.validate((valid, obj) => {
+          if (obj) {
+            let messages = Object.keys(obj).map((key) => obj[key][0]);
+            if (messages.length > 0) {
+              this.$message.warning(messages[0].message);
+            }
           }
-        ];
-      }
-      if (this.detailList.length > 0) {
-        this.form.tableList = this.detailList;
+          if (!valid) {
+            reject(false);
+          } else {
+            resolve(true);
+          }
+        });
+      });
+    },
+    addBank() {
+      this.form.tableList.push({
+        typeId: '2',
+        code: '',
+        name: '',
+        categoryModel: '',
+        specification: '',
+        content: '',
+        totalCount: 1,
+        measureUnit: '',
+        singlePrice: '',
+        settlementPrice: ''
+      });
+    },
+    async addEquipment(row, index) {
+      // const res = await parameterGetByCode({
+      //   code: 'after_sales_accessory_source'
+      // });
+      this.currentIndex = index;
+      if (this.obtain == '仓库') {
+        this.$refs.productListRef.open('', index, '0');
+      } else {
+        this.$refs.productListRef.open('', index, '1');
       }
     },
-    methods: {
-      init(row) {},
-      async getLevelCode(code) {
-        try {
-          const res = await getByCode(code);
-          if (res.code == 0) {
-            let list = Object.values(res.data).map((el) => {
-              let k = Object.keys(el)[0];
-              let v = Object.values(el)[0];
-              return {
-                label: v,
-                value: k
-              };
-            });
-            this.typeIdList = list;
-          }
-        } catch (err) {
-          this.$message.error(err.message);
-        }
-      },
-      typeIdChange(row, index) {
-        let obj = {
-          typeId: row.typeId,
-          code: '',
-          name: '',
-          categoryModel: '',
-          specification: '',
-          content: '',
-          totalCount: 1,
-          measureUnit: '',
-          singlePrice: '',
-          settlementPrice: ''
-        };
-        let o = this.typeIdList.find((item) => item.value == row.typeId);
-        if (o.value != 2) {
-          obj.name = o.label;
-        }
-        this.$set(this.form.tableList, index, obj);
-      },
-      getValidate() {
-        return new Promise((resolve, reject) => {
-          this.$refs.form.validate((valid, obj) => {
-            if (obj) {
-              let messages = Object.keys(obj).map((key) => obj[key][0]);
-              if (messages.length > 0) {
-                this.$message.warning(messages[0].message);
-              }
-            }
-            if (!valid) {
-              reject(false);
-            } else {
-              resolve(true);
-            }
+    getTableValue() {
+      return this.form.tableList;
+    },
+    async setTableValue(val) {
+      const tableList = JSON.parse(JSON.stringify(val));
+      for (let i = 0; i < tableList.length; i++) {
+        const item = tableList[i];
+        item.categoryCode = item.categoryCode || item.code;
+        item.categoryName = item.categoryName || item.name;
+        if (item.typeId == 2) {
+          const warehouseList = await getIdWarehouseList({
+            categoryId: item.categoryId
           });
-        });
-      },
-      addBank() {
-        this.form.tableList.push({
-          typeId: '2',
-          code: '',
-          name: '',
-          categoryModel: '',
-          specification: '',
-          content: '',
-          totalCount: 1,
-          measureUnit: '',
-          singlePrice: '',
-          settlementPrice: ''
-        });
-      },
-      async addEquipment(row, index) {
-        // const res = await parameterGetByCode({
-        //   code: 'after_sales_accessory_source'
-        // });
-        this.currentIndex = index;
-        if (this.obtain == '仓库') {
-          this.$refs.productListRef.open('', index, '0');
-        } else {
-          this.$refs.productListRef.open('', index, '1');
-        }
-      },
-      getTableValue() {
-        return this.form.tableList;
-      },
-      setTableValue(val) {
-        this.$set(this.form, 'tableList', val);
-        this.form.tableList.forEach(async (item, index) => {
-          if (item.typeId == 2) {
-            this.$set(
-              this.form.tableList[index],
-              'warehouseList',
-              await getIdWarehouseList({
-                categoryId: item.categoryId
-              })
-            );
-            if (item.warehouseId) {
-              this.$set(
-                this.form.tableList[index],
-                'warehouseNum',
-                await getWarehouseOutStock({
-                  warehouseId: item.warehouseId,
-                  code: item.code
-                })
-              );
-            }
+          item.warehouseList = warehouseList;
+          if (item.warehouseId) {
+            item.warehouseNum = await getWarehouseOutStock({
+              warehouseId: item.warehouseId,
+              code: item.categoryCode
+            });
           }
-        });
-        // ***
-        this.calculatePrice();
-      },
-      totalCountChange(index, data, name) {
-        data[name] = data[name].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
-        let row = this.form.tableList[index];
-        if (row.totalCount && row.singlePrice) {
-          row.settlementPrice = row.totalCount * row.singlePrice;
-        } else {
-          row.settlementPrice = 0;
         }
-        this.$set(
-          this.form.tableList[index],
-          'settlementPrice',
-          row.settlementPrice || 0
-        );
-        this.calculatePrice();
-      },
-      clearList() {
-        this.form.tableList = [];
-      },
-      // 计算汇总价格 ***
-      calculatePrice() {
-        let totlal = 0;
-        this.form.tableList.map((el) => (totlal += el.settlementPrice));
-        this.totalPrice = totlal;
-      },
-      del(row, index) {
-        this.form.tableList.splice(index, 1);
-      },
-      async confirmChoose(data) {
-        this.$set(this.form.tableList, this.currentIndex, data[0]);
-        this.$set(
-          this.form.tableList[this.currentIndex],
-          'categoryModel',
-          data[0].modelType
-        );
-        this.$set(
-          this.form.tableList[this.currentIndex],
-          'categoryId',
-          data[0].id
-        );
-        this.$set(
-          this.form.tableList[this.currentIndex],
-          'measureUnit',
-          data[0].measuringUnit
-        );
+      }
+      this.$set(this.form, 'tableList', tableList);
+      this.calculatePrice();
+    },
+    totalCountChange(index, data, name) {
+      data[name] = data[name].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
+      let row = this.form.tableList[index];
+      if (row.totalCount && row.singlePrice) {
+        row.settlementPrice = row.totalCount * row.singlePrice;
+      } else {
+        row.settlementPrice = 0;
+      }
+      this.$set(
+        this.form.tableList[index],
+        'settlementPrice',
+        row.settlementPrice || 0
+      );
+      this.calculatePrice();
+    },
+    clearList() {
+      this.form.tableList = [];
+    },
+    // 计算汇总价格 ***
+    calculatePrice() {
+      let totlal = 0;
+      this.form.tableList.map((el) => (totlal += el.settlementPrice));
+      this.totalPrice = totlal;
+    },
+    del(row, index) {
+      this.form.tableList.splice(index, 1);
+    },
+    async confirmChoose(data) {
+      this.$set(this.form.tableList, this.currentIndex, data[0]);
+      this.$set(
+        this.form.tableList[this.currentIndex],
+        'categoryModel',
+        data[0].modelType
+      );
+      this.$set(
+        this.form.tableList[this.currentIndex],
+        'categoryId',
+        data[0].id
+      );
+      this.$set(
+        this.form.tableList[this.currentIndex],
+        'measureUnit',
+        data[0].measuringUnit
+      );
 
-        this.$set(
+      this.$set(
+        this.form.tableList[this.currentIndex],
+        'warehouseList',
+        await getIdWarehouseList({
+          categoryId: data[0].id
+        })
+      );
+      if (this.form.tableList[this.currentIndex]?.warehouseList?.length) {
+        this.warehouseChange(
+          this.form.tableList[this.currentIndex].warehouseList[0],
           this.form.tableList[this.currentIndex],
-          'warehouseList',
-          await getIdWarehouseList({
-            categoryId: data[0].id
-          })
-        );
-        if (this.form.tableList[this.currentIndex]?.warehouseList?.length) {
-          this.warehouseChange(
-            this.form.tableList[this.currentIndex].warehouseList[0],
-            this.form.tableList[this.currentIndex],
-            this.currentIndex
-          );
-        }
-
-        this.$set(this.form.tableList[this.currentIndex], 'typeId', '2');
-        this.$forceUpdate();
-      },
-      async warehouseChange(item, row, index) {
-        this.$set(
-          this.form.tableList[index],
-          'warehouseName',
-          item.warehouseName
-        );
-        this.$set(this.form.tableList[index], 'warehouseId', item.warehouseId);
-        this.$set(
-          this.form.tableList[index],
-          'warehouseNum',
-          await getWarehouseOutStock({
-            warehouseId: item.warehouseId,
-            code: row.code
-          })
+          this.currentIndex
         );
       }
+
+      this.$set(this.form.tableList[this.currentIndex], 'typeId', '2');
+      this.$forceUpdate();
+    },
+    async warehouseChange(item, row, index) {
+      this.$set(
+        this.form.tableList[index],
+        'warehouseName',
+        item.warehouseName
+      );
+      this.$set(this.form.tableList[index], 'warehouseId', item.warehouseId);
+      this.$set(
+        this.form.tableList[index],
+        'warehouseNum',
+        await getWarehouseOutStock({
+          warehouseId: item.warehouseId,
+          code: row.code
+        })
+      );
     }
-  };
+  }
+};
 </script>
 <style lang="scss" scoped>
-  :deep(.el-table__body .el-form-item__content) {
-    margin-left: 0px !important;
-  }
-  :deep(.el-table__body .el-form-item) {
-    margin-bottom: 0px !important;
-  }
-  .total_price {
-    margin-left: 24px;
-  }
+:deep(.el-table__body .el-form-item__content) {
+  margin-left: 0px !important;
+}
+:deep(.el-table__body .el-form-item) {
+  margin-bottom: 0px !important;
+}
+.total_price {
+  margin-left: 24px;
+}
 
-  .toobar {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
-    padding-right: 16px;
-  }
+.toobar {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  padding-right: 16px;
+}
 
-  .toobar_r {
-    justify-content: flex-end;
-  }
+.toobar_r {
+  justify-content: flex-end;
+}
 </style>

+ 2 - 2
src/views/salesServiceManagement/demandList/components/addDialog.vue

@@ -168,8 +168,8 @@ export default {
       let sparePartsData = (this.$refs.infoRef.getSpareInfoData() || []).map(
         (item) => ({
           ...item,
-          code: item?.categoryCode,
-          name: item?.categoryName
+          code: item.categoryCode,
+          name: item.categoryName
         })
       );