Jelajahi Sumber

售后工单 报工时间选择 bug修复

jingshuyong 11 bulan lalu
induk
melakukan
1b7f6563fe

+ 485 - 459
src/BIZComponents/product-list.vue

@@ -11,7 +11,12 @@
   >
     <el-card shadow="never">
       <searchProduct v-if="dataSources == '1'" @search="reload"></searchProduct>
-      <el-form :model="searchForm" label-width="100px" @submit.native.prevent v-else>
+      <el-form
+        :model="searchForm"
+        label-width="100px"
+        @submit.native.prevent
+        v-else
+      >
         <el-row>
           <el-row>
             <!-- <el-col :span="6">
@@ -28,7 +33,11 @@
             </el-col> -->
             <el-col :span="6">
               <el-form-item label="牌号">
-                <el-input type="text" placeholder="搜索牌号" v-model="searchForm.brandNum"></el-input>
+                <el-input
+                  type="text"
+                  placeholder="搜索牌号"
+                  v-model="searchForm.brandNum"
+                ></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="6" style="height: 43px">
@@ -68,9 +77,11 @@
                 ></el-input>
               </el-form-item>
             </el-col>
-            <el-col style="text-align: right;margin-bottom: 10px;">
+            <el-col style="text-align: right; margin-bottom: 10px">
               <el-button type="primary" @click="doSearch">搜索</el-button>
-              <el-button icon="el-icon-refresh-left" @click="reset">重置</el-button>
+              <el-button icon="el-icon-refresh-left" @click="reset"
+                >重置</el-button
+              >
             </el-col>
           </el-row>
           <!-- <el-row>
@@ -97,7 +108,11 @@
           </el-row> -->
         </el-row>
       </el-form>
-      <ele-split-layout width="244px" allow-collapse :right-style="{ overflow: 'hidden' }">
+      <ele-split-layout
+        width="244px"
+        allow-collapse
+        :right-style="{ overflow: 'hidden' }"
+      >
         <div class="ele-border-lighter split-layout-right-content">
           <productTree
             @handleNodeClick="handleNodeClick"
@@ -105,6 +120,7 @@
             ref="treeList"
             :ids="ids"
             :typeIds="typeIds"
+            :itemType="itemType"
           />
         </div>
         <!-- 表格 -->
@@ -133,7 +149,9 @@
               </el-radio>
             </template>
             <template v-slot:cz="{ row }">
-              <el-button type="text" @click="handleDoubleClick(row)">选择Bom</el-button>
+              <el-button type="text" @click="handleDoubleClick(row)"
+                >选择Bom</el-button
+              >
             </template>
           </ele-pro-table>
         </template>
@@ -155,491 +173,499 @@
 </template>
 
 <script>
-import {
-  getOutindetailtwoList,
-  getBatchList,
-  getMaterialList,
-  getPackingList
-} from '@/api/wms';
-import {
-  getProductList,
-  queryLastContractProductList
-} from '@/api/saleManage/quotation';
-import searchProduct from './searchProduct.vue';
-import productTree from '@/components/productTree';
-import { getInventoryTotalAPI } from '@/api/wms';
-import cBomList from './cBom-list.vue';
-import { getByCode } from '@/api/system/dictionary-data';
-import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
-import { lbjtList } from '@/enum/dict.js';
-import tabMixins from '@/mixins/tableColumnsMixin';
+  import {
+    getOutindetailtwoList,
+    getBatchList,
+    getMaterialList,
+    getPackingList
+  } from '@/api/wms';
+  import {
+    getProductList,
+    queryLastContractProductList
+  } from '@/api/saleManage/quotation';
+  import searchProduct from './searchProduct.vue';
+  import productTree from '@/components/productTree';
+  import { getInventoryTotalAPI } from '@/api/wms';
+  import cBomList from './cBom-list.vue';
+  import { getByCode } from '@/api/system/dictionary-data';
+  import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
+  import { lbjtList } from '@/enum/dict.js';
+  import tabMixins from '@/mixins/tableColumnsMixin';
 
-export default {
-  mixins: [tabMixins],
+  export default {
+    mixins: [tabMixins],
 
-  components: {
-    productTree,
-    searchProduct,
-    cBomList
-  },
-  props: {
-    /*是否需要获取仓库产品数量*/
-    isGetInventoryTotal: {
-      type: Boolean,
-      default: false
-    },
-    /*已选择的产品*/
-    data: {
-      type: Array,
-      default: () => []
-    },
-    /*是否需要cBom*/
-    isShowCBom: {
-      type: Boolean,
-      default: false
-    },
-    /*是否需要供应商*/
-    isSupplier: {
-      type: Boolean,
-      default: false
-    },
-    //获取上一次销售记录  1销售合同 2采购合同
-    isSalesRecord: {
-      default: ''
-    },
-    typeIds: {
-      type: Array,
-      default: () => []
+    components: {
+      productTree,
+      searchProduct,
+      cBomList
     },
-    isFirstRefreshTable: {
-      type: Boolean,
-      default: false
-    },
-    ids: {
-      type: Array,
-      default: () => []
-    }
-  },
-
-  data() {
-    return {
-      visible: false,
-      currentIndex: null,
-      radio: null,
-      cBomListDialogFlag: null,
-      dictList: {},
-      selection: [],
-      isColorId: [],
-      dataSources: '1', // 0:仓库;1:主数据
-      dimension: '1',
-      searchForm: {
-        categoryCode: '',
-        categoryName: '',
-        batchNo: '',
-        brandNum: '',
-        engrave: '',
-        barcodes: '',
-        categoryLevelId: '',
-        warehouseId: '',
-        pageNum: 1,
-        size: 10
+    props: {
+      /*是否需要获取仓库产品数量*/
+      isGetInventoryTotal: {
+        type: Boolean,
+        default: false
       },
-      datasourceList: []
-    };
-  },
-  watch: {},
-  computed: {
-    columns() {
-      let data = null;
-      if (this.currentIndex != -1) {
-        data = {
-          action: 'action',
-          slot: 'action',
-          align: 'center',
-          label: '选择',
-          reserveSelection: true
-        };
-      }
-      if (this.currentIndex == -1) {
-        data = {
-          label: '选择',
-          width: 45,
-          type: 'selection',
-          columnKey: 'selection',
-          align: 'center',
-          reserveSelection: true
-        };
+      /*已选择的产品*/
+      data: {
+        type: Array,
+        default: () => []
+      },
+      /*是否需要cBom*/
+      isShowCBom: {
+        type: Boolean,
+        default: false
+      },
+      /*是否需要供应商*/
+      isSupplier: {
+        type: Boolean,
+        default: false
+      },
+      //获取上一次销售记录  1销售合同 2采购合同
+      isSalesRecord: {
+        default: ''
+      },
+      typeIds: {
+        type: Array,
+        default: () => []
+      },
+      isFirstRefreshTable: {
+        type: Boolean,
+        default: false
+      },
+      ids: {
+        type: Array,
+        default: () => []
+      },
+      itemType: {
+        type: String,
+        default: '1'
       }
+    },
 
-      return [
-        data,
-        {
-          columnKey: 'index',
-          type: 'index',
-          width: 50,
-          align: 'center',
-          showOverflowTooltip: true,
-          label: '序号'
-        },
-        {
-          prop: 'code',
-          label: '编码',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'name',
-          label: '名称',
-          align: 'center',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'imgCode',
-          align: 'center',
-          label: '图号/件号',
-          showOverflowTooltip: true,
-          minWidth: 110
+    data() {
+      return {
+        visible: false,
+        currentIndex: null,
+        radio: null,
+        cBomListDialogFlag: null,
+        dictList: {},
+        selection: [],
+        isColorId: [],
+        dataSources: '1', // 0:仓库;1:主数据
+        dimension: '1',
+        searchForm: {
+          categoryCode: '',
+          categoryName: '',
+          batchNo: '',
+          brandNum: '',
+          engrave: '',
+          barcodes: '',
+          categoryLevelId: '',
+          warehouseId: '',
+          pageNum: 1,
+          size: 10
         },
-        {
-          prop: 'componentAttribute',
-          align: 'center',
-          label: '属性类型',
-          showOverflowTooltip: true,
-          formatter: (row, column) => {
-            if (row.produceType) {
-              return row.produceType
-                .map((item) => {
-                  return lbjtList[item];
-                })
-                .toString();
-            }
+        datasourceList: []
+      };
+    },
+    watch: {},
+    computed: {
+      columns() {
+        let data = null;
+        if (this.currentIndex != -1) {
+          data = {
+            action: 'action',
+            slot: 'action',
+            align: 'center',
+            label: '选择',
+            reserveSelection: true
+          };
+        }
+        if (this.currentIndex == -1) {
+          data = {
+            label: '选择',
+            width: 45,
+            type: 'selection',
+            columnKey: 'selection',
+            align: 'center',
+            reserveSelection: true
+          };
+        }
+
+        return [
+          data,
+          {
+            columnKey: 'index',
+            type: 'index',
+            width: 50,
+            align: 'center',
+            showOverflowTooltip: true,
+            label: '序号'
+          },
+          {
+            prop: 'code',
+            label: '编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'name',
+            label: '名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'imgCode',
+            align: 'center',
+            label: '图号/件号',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'componentAttribute',
+            align: 'center',
+            label: '属性类型',
+            showOverflowTooltip: true,
+            formatter: (row, column) => {
+              if (row.produceType) {
+                return row.produceType
+                  .map((item) => {
+                    return lbjtList[item];
+                  })
+                  .toString();
+              }
+            },
+            minWidth: 110
+          },
+          // {
+          //   prop: 'extField.approvalNumber',
+          //   align: 'center',
+          //   label: '批准文号',
+          //   showOverflowTooltip: true,
+          //   minWidth: 110
+          // },
+          {
+            prop: 'extField.packingSpecification',
+            align: 'center',
+            label: '包装规格',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'brandNum',
+            align: 'center',
+            label: '牌号',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'modelType',
+            label: '型号',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specification',
+            label: '规格',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 90
           },
-          minWidth: 110
-        },
-        // {
-        //   prop: 'extField.approvalNumber',
-        //   align: 'center',
-        //   label: '批准文号',
-        //   showOverflowTooltip: true,
-        //   minWidth: 110
-        // },
-        {
-          prop: 'extField.packingSpecification',
-          align: 'center',
-          label: '包装规格',
-          showOverflowTooltip: true,
-          minWidth: 110
-        },
-        {
-          prop: 'brandNum',
-          align: 'center',
-          label: '牌号',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'modelType',
-          label: '型号',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'specification',
-          label: '规格',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'measuringUnit',
-          label: '计量单位',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 90
-        },
 
-        {
-          prop: 'weightUnit',
-          label: '重量单位',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 90
-        },
+          {
+            prop: 'weightUnit',
+            label: '重量单位',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 90
+          },
 
-        {
-          prop: 'roughWeight',
-          label: '毛重',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 90
-        },
+          {
+            prop: 'roughWeight',
+            label: '毛重',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 90
+          },
 
-        {
-          prop: 'netWeight',
-          label: '净重',
-          showOverflowTooltip: true,
-          align: 'center',
-          minWidth: 90
-        },
+          {
+            prop: 'netWeight',
+            label: '净重',
+            showOverflowTooltip: true,
+            align: 'center',
+            minWidth: 90
+          },
 
-        {
-          prop: 'packingUnit',
-          align: 'center',
-          label: '包装单位',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'categoryLevelPath',
-          label: '分类',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          slot: 'cz',
-          align: 'center',
-          minWidth: 90,
-          fixed: 'right',
-          label: '操作',
-          show: this.isShowCBom
-        }
-      ];
-    }
-  },
-  methods: {
-    getDictV(code, val) {
-      if (!this.dictList[code]) return '';
-      return this.dictList[code].find((item) => item.value == val)?.label;
-    },
-    async getDictList(code) {
-      let { data: res } = await getByCode(code);
-      this.dictList[code] = res.map((item) => {
-        let values = Object.keys(item);
-        return {
-          value: values[0],
-          label: item[values[0]]
-        };
-      });
-    },
-    open(item, currentIndex, value) {
-      this.dataSources = value || '1';
-      this.currentIndex = currentIndex;
-      this.visible = true;
-      this.getDictList('productionType');
-    },
-    /* 表格数据源 */
-    datasource({ page, limit, where, order }) {
-     if(this.dataSources == '0'){
-      this.searchForm.pageNum = page;
-      return this.changeDimension(this.dimension);
-     }
-      return getProductList({
-        pageNum: page,
-        size: limit,
-        ...where
-      });
-    },
-    async tableDone() {
-      if (this.isSalesRecord == 1 || this.isSalesRecord == 2) {
-        this.isColorId = await queryLastContractProductList(this.isSalesRecord);
-      }
-    },
-    //上次销售记录 改变背景色
-    tableRowClassName({ row }) {
-      if (this.isColorId?.includes(row?.id)) {
-        return 'success-row';
+          {
+            prop: 'packingUnit',
+            align: 'center',
+            label: '包装单位',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'categoryLevelPath',
+            label: '分类',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            slot: 'cz',
+            align: 'center',
+            minWidth: 90,
+            fixed: 'right',
+            label: '操作',
+            show: this.isShowCBom
+          }
+        ];
       }
-      return '';
     },
+    methods: {
+      getDictV(code, val) {
+        if (!this.dictList[code]) return '';
+        return this.dictList[code].find((item) => item.value == val)?.label;
+      },
+      async getDictList(code) {
+        let { data: res } = await getByCode(code);
+        this.dictList[code] = res.map((item) => {
+          let values = Object.keys(item);
+          return {
+            value: values[0],
+            label: item[values[0]]
+          };
+        });
+      },
+      open(item, currentIndex, value) {
+        this.dataSources = value || '1';
+        this.currentIndex = currentIndex;
+        this.visible = true;
+        this.getDictList('productionType');
+      },
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        if (this.dataSources == '0') {
+          this.searchForm.pageNum = page;
+          return this.changeDimension(this.dimension);
+        }
+        return getProductList({
+          pageNum: page,
+          size: limit,
+          ...where
+        });
+      },
+      async tableDone() {
+        if (this.isSalesRecord == 1 || this.isSalesRecord == 2) {
+          this.isColorId = await queryLastContractProductList(
+            this.isSalesRecord
+          );
+        }
+      },
+      //上次销售记录 改变背景色
+      tableRowClassName({ row }) {
+        if (this.isColorId?.includes(row?.id)) {
+          return 'success-row';
+        }
+        return '';
+      },
 
-    /* 刷新表格 */
-    reload(where) {
-      where.categoryLevelId = this.curNodeData?.id;
-      this.searchForm.categoryLevelId = this.curNodeData?.id;
-      this.$refs.table.reload({ pageNum: 1, where: where });
-    },
+      /* 刷新表格 */
+      reload(where) {
+        where.categoryLevelId = this.curNodeData?.id;
+        this.searchForm.categoryLevelId = this.curNodeData?.id;
+        this.$refs.table.reload({ pageNum: 1, where: where });
+      },
 
-    handleNodeClick(data, node) {
-      this.curNodeData = data;
-      this.$nextTick(() => {
-        this.reload({ categoryLevelId: data.id });
-      });
-    },
+      handleNodeClick(data, node) {
+        this.curNodeData = data;
+        this.$nextTick(() => {
+          this.reload({ categoryLevelId: data.id });
+        });
+      },
 
-    // 单击获取id
-    cellClick(row) {
-      if (this.currentIndex == -1) return;
-      this.current = row;
-      this.radio = row.id;
-    },
-    handleDoubleClick(row) {
-      if (!this.isShowCBom) return;
-      this.cBomListDialogFlag = true;
-      this.current = row;
-      this.$nextTick(() => {
-        this.$refs.cBomRef.open(row);
-      });
-    },
-    getSelectionCbom(rows = []) {
-      this.$emit('getSelectionCbom', rows);
-      this.handleClose();
-    },
-    handleClose() {
-      this.visible = false;
-      this.current = null;
-      this.selection = [];
-      this.$refs.table.clearSelection();
-      this.radio = '';
-    },
-    async getSupplierObj(productList, queryName) {
-      try {
-        let categoryIds = productList
-          .filter((item) => item.id)
-          .map((item) => item.id);
-        if (categoryIds.length > 0) {
-          return await contactQueryByCategoryIdsAPI({
-            categoryIds,
-            isQueryEE: 1
-          });
-        } else {
+      // 单击获取id
+      cellClick(row) {
+        if (this.currentIndex == -1) return;
+        this.current = row;
+        this.radio = row.id;
+      },
+      handleDoubleClick(row) {
+        if (!this.isShowCBom) return;
+        this.cBomListDialogFlag = true;
+        this.current = row;
+        this.$nextTick(() => {
+          this.$refs.cBomRef.open(row);
+        });
+      },
+      getSelectionCbom(rows = []) {
+        this.$emit('getSelectionCbom', rows);
+        this.handleClose();
+      },
+      handleClose() {
+        this.visible = false;
+        this.current = null;
+        this.selection = [];
+        this.$refs.table.clearSelection();
+        this.radio = '';
+      },
+      async getSupplierObj(productList, queryName) {
+        try {
+          let categoryIds = productList
+            .filter((item) => item.id)
+            .map((item) => item.id);
+          if (categoryIds.length > 0) {
+            return await contactQueryByCategoryIdsAPI({
+              categoryIds,
+              isQueryEE: 1
+            });
+          } else {
+            return Promise.resolve({});
+          }
+        } catch (e) {
           return Promise.resolve({});
         }
-      } catch (e) {
-        return Promise.resolve({});
-      }
-    },
-    async selected() {
-      if (!this.current && !this.selection.length) {
-        return this.$message.warning('请至少选择一条数据');
-      }
-      if (this.currentIndex != -1) {
-        if (
-          this.data.map((item) => item.productCode).includes(this.current.code)
-        ) {
-          return this.$message.error('选择的物品已经存在列表了');
+      },
+      async selected() {
+        if (!this.current && !this.selection.length) {
+          return this.$message.warning('请至少选择一条数据');
+        }
+        if (this.currentIndex != -1) {
+          if (
+            this.data
+              .map((item) => item.productCode)
+              .includes(this.current.code)
+          ) {
+            return this.$message.error('选择的物品已经存在列表了');
+          }
+        } else {
+          if (
+            this.selection.some((item) =>
+              this.data.some((i) => i.productCode == item.code)
+            )
+          ) {
+            return this.$message.error('选择的物品已经存在列表了');
+          }
         }
-      } else {
-        if (
-          this.selection.some((item) =>
-            this.data.some((i) => i.productCode == item.code)
-          )
-        ) {
-          return this.$message.error('选择的物品已经存在列表了');
+
+        let codeList = [];
+        let list = this.currentIndex == -1 ? this.selection : [this.current];
+        //获取仓库库存
+        if (this.isGetInventoryTotal) {
+          codeList = list.map((item) => item.code);
+          let inventoryTotalList = await getInventoryTotalAPI(codeList);
+          list.forEach((item) => {
+            let find =
+              inventoryTotalList.find((key) => key.code == item.code) || {};
+            item.availableCountBase = find.availableCountBase;
+          });
         }
-      }
+        //获取供应商
+        if (this.isSupplier) {
+          let supplierList = await this.getSupplierObj(list);
+          list.forEach((item) => {
+            item['entrustedEnterpriseIdList'] = supplierList[item.id];
+            if (supplierList[item.id]?.length === 1) {
+              item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
+            }
+          });
+        }
+        this.$emit('changeParent', list, this.currentIndex);
+        this.handleClose();
+      },
+      // 仓库查询
+      doSearch() {
+        // this.searchForm.pageNum = 1;
+        this.reload({ pageNum: 1, where: this.searchForm });
+      },
 
-      let codeList = [];
-      let list = this.currentIndex == -1 ? this.selection : [this.current];
-      //获取仓库库存
-      if (this.isGetInventoryTotal) {
-        codeList = list.map((item) => item.code);
-        let inventoryTotalList = await getInventoryTotalAPI(codeList);
-        list.forEach((item) => {
-          let find =
-            inventoryTotalList.find((key) => key.code == item.code) || {};
-          item.availableCountBase = find.availableCountBase;
-        });
-      }
-      //获取供应商
-      if (this.isSupplier) {
-        let supplierList = await this.getSupplierObj(list);
-        list.forEach((item) => {
-          item['entrustedEnterpriseIdList'] = supplierList[item.id];
-          if (supplierList[item.id]?.length === 1) {
-            item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
-          }
+      // 仓库查询重置
+      reset() {
+        this.searchForm = {
+          categoryCode: '',
+          categoryName: '',
+          batchNo: '',
+          brandNum: '',
+          engrave: '',
+          barcodes: '',
+          categoryLevelId: this.categoryLevelId,
+          pageNum: 1,
+          warehouseId: '',
+          size: 10
+        };
+        this.doSearch();
+      },
+      // 切换维度
+      changeDimensionHandler(e) {
+        // this.searchForm.pageNum = 1;
+        // this.selectionList = [];
+        // this.$refs.multipleTable.clearSelection();
+        this.reload({ pageNum: 1, where: this.searchForm });
+      },
+      // 仓库数据
+      async changeDimension(e) {
+        this.dimension = e;
+        let data = [];
+        if (this.dimension == 1) {
+          // 物品维度
+          data = await getOutindetailtwoList(this.searchForm);
+        } else if (this.dimension == 2) {
+          // 批次维度
+          data = await getBatchList(this.searchForm);
+        } else if (this.dimension == 4) {
+          // 物料维度
+          data = await getMaterialList(this.searchForm);
+        } else {
+          // 包装维度
+          data = await getPackingList(this.searchForm);
+        }
+        data.list.map((el) => {
+          el.modelType = el.categoryModel;
+          el.name = el.categoryName;
+          el.code = el.categoryCode;
         });
+        return data;
       }
-      this.$emit('changeParent', list, this.currentIndex);
-      this.handleClose();
-    },
-    // 仓库查询
-    doSearch() {
-    // this.searchForm.pageNum = 1;
-     this.reload({pageNum: 1, where: this.searchForm})
-    },
-
-    // 仓库查询重置
-    reset() {
-      this.searchForm = {
-        categoryCode: '',
-        categoryName: '',
-        batchNo: '',
-        brandNum: '',
-        engrave: '',
-        barcodes: '',
-        categoryLevelId: this.categoryLevelId,
-        pageNum: 1,
-        warehouseId: '',
-        size: 10
-      };
-      this.doSearch();
-    },
-    // 切换维度
-    changeDimensionHandler(e) {
-      // this.searchForm.pageNum = 1;
-      // this.selectionList = [];
-      // this.$refs.multipleTable.clearSelection();
-      this.reload({pageNum: 1, where: this.searchForm});
-    },
-    // 仓库数据
-    async changeDimension(e) {
-      this.dimension = e;
-      let data = [];
-      if (this.dimension == 1) {
-        // 物品维度
-         data = await getOutindetailtwoList(this.searchForm);
-      } else if (this.dimension == 2) {
-        // 批次维度
-         data = await getBatchList(this.searchForm);
-      } else if (this.dimension == 4) {
-        // 物料维度
-         data = await getMaterialList(this.searchForm);
-      } else {
-        // 包装维度
-         data = await getPackingList(this.searchForm);
-      }
-      data.list.map((el)=>{
-        el.modelType = el.categoryModel;
-        el.name = el.categoryName;
-        el.code = el.categoryCode;
-      })
-      return data
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-:deep(.success-row) {
-  background: #f0f9eb;
-}
-.tree_col {
-  border: 1px solid #eee;
-  padding: 10px 0;
-  box-sizing: border-box;
-  height: 500px;
-  overflow: auto;
-}
+  :deep(.success-row) {
+    background: #f0f9eb;
+  }
+  .tree_col {
+    border: 1px solid #eee;
+    padding: 10px 0;
+    box-sizing: border-box;
+    height: 500px;
+    overflow: auto;
+  }
 
-.table_col {
-  padding-left: 10px;
+  .table_col {
+    padding-left: 10px;
 
-  ::v-deep .el-table th.el-table__cell {
-    background: #f2f2f2;
+    ::v-deep .el-table th.el-table__cell {
+      background: #f2f2f2;
+    }
   }
-}
 
-.pagination {
-  text-align: right;
-  padding: 10px 0;
-}
+  .pagination {
+    text-align: right;
+    padding: 10px 0;
+  }
 
-.btns {
-  text-align: center;
-  padding: 10px 0;
-}
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
 
-.topsearch {
-  margin-bottom: 15px;
-}
+  .topsearch {
+    margin-bottom: 15px;
+  }
 </style>

+ 2 - 2
src/api/saleManage/quotation.js

@@ -74,10 +74,10 @@ export async function getExport(id) {
  * 产品分类
  */
 
-export async function getProduceTreeByPid() {
+export async function getProduceTreeByPid(type=1) {
   const res = await request.get(
     //`/main/categoryLevel/getTreeByPid/9`,
-    `/main/categoryLevel/getProduceTreeByPid?type=1`,
+    `/main/categoryLevel/getProduceTreeByPid?type=`+type,
     {}
   );
   if (res.data.code == 0) {

+ 6 - 1
src/components/productTree/index.vue

@@ -20,6 +20,7 @@
 <script>
   import { getProduceTreeByPid } from '@/api/saleManage/quotation';
   import { getInfoByIds,getTreeByIds } from '@/api/classifyManage/index';
+
   // let originId = '';
   // let originType = '';
   export default {
@@ -70,6 +71,10 @@
       ids:{
         type: Array,
         default: () => []
+      },
+      itemType:{
+        type:String,
+        default:'1'
       }
       // appendRoot: {
       //   type: Boolean,
@@ -108,7 +113,7 @@
             data= res.data
 
           } else {
-            data = await getProduceTreeByPid(params);
+            data = await getProduceTreeByPid(this.itemType);
           }
           console.log(data,'data')
 

+ 191 - 0
src/components/productTree/itemTree.vue

@@ -0,0 +1,191 @@
+<template>
+  <div class="tree-wrapper">
+    <el-tree
+      :data="treeList"
+      :props="defaultProps"
+      v-loading="treeLoading"
+      :node-key="nodeKey"
+      ref="tree"
+      :highlight-current="true"
+      :expand-on-click-node="false"
+      @node-click="handleNodeClick"
+      :default-expanded-keys="defaultExpandedKeys"
+      v-bind="$attrs"
+      :default-expand-all="defaultExpandAll"
+    >
+    </el-tree>
+  </div>
+</template>
+
+<script>
+  import { getProduceTreeByPid } from '@/api/saleManage/quotation';
+  import { getInfoByIds,getTreeByIds } from '@/api/classifyManage/index';
+  import { getTreeByGroup } from '@/api/wms'
+  // let originId = '';
+  // let originType = '';
+  export default {
+    props: {
+      // treeList私有化处理
+      treeFormate: {
+        type: Function,
+        default: null
+      },
+      defaultProps: {
+        type: Object,
+        default: function () {
+          return {
+            children: 'children',
+            value: 'id',
+            label: 'name'
+          };
+        }
+      },
+      defaultExpandAll: {
+        type: Boolean,
+        default: function () {
+          return false;
+        }
+      },
+      // 初始请求treeList
+      init: {
+        type: Boolean,
+        default: true
+      },
+
+      isFirstRefreshTable: {
+        type: Boolean,
+        default: true
+      },
+      id: {
+        type: String,
+        default: '0'
+      },
+      nodeKey: {
+        type: String,
+        default: 'id'
+      },
+      typeIds: {
+        type: Array,
+        default: () => []
+      },
+      ids:{
+        type: Array,
+        default: () => []
+      }
+      // appendRoot: {
+      //   type: Boolean,
+      //   default: false
+      // },
+    },
+    data() {
+      return {
+        defaultExpandedKeys: [],
+        treeList: [],
+        treeLoading: false,
+        parentName: '',
+        parentId: '',
+        currentKey: ''
+      };
+    },
+    mounted() {
+      if (this.init) {
+        this.getTreeData();
+      }
+    },
+    methods: {
+      getInstance() {
+        return this.$refs.tree;
+      },
+      // 获取树结构数据
+      async getTreeData(params = {}) {
+        try {
+          
+          this.treeLoading = true;
+          let data = {};
+          if (this.typeIds.length > 0) {
+            let res = await getInfoByIds(this.typeIds.toString());
+            data= res.data
+          }else if(this.ids.length > 0){
+            let res = await getTreeByIds({ ids: this.ids.join(',') });
+            data= res.data
+
+          } else {
+            data = await getProduceTreeByPid(params);
+          }
+          console.log(data,'data')
+
+          this.treeLoading = false;
+          this.$emit('setRootId', data[0].id);
+          this.treeList = this.$util.toTreeData({
+            data: data || [],
+            idField: 'id',
+            parentIdField: 'parentId'
+          });
+          this.defaultExpandedKeys = [this.treeList[0].id || ''];
+          this.$nextTick(() => {
+            // 默认高亮第一级树节点
+            if (this.treeList[0] && this.isFirstRefreshTable) {
+              this.setCurrentKey(this.treeList[0].id);
+              this.handleNodeClick(
+                this.treeList[0],
+                this.$refs.tree.getCurrentNode()
+              );
+            }
+          });
+          
+          return this.treeList;
+        } catch (error) {
+          console.error(error);
+        }
+        this.treeLoading = false;
+      },
+      // 递归 - 往树children里面添加parentName
+      // _setParentName (tree) {
+      //   let data = tree;
+      //   for (let i = 0; i < data.length; i++) {
+      //     if (data[i].parentId === '0') {
+      //       this.parentName = data[i].name;
+      //       originId = data[i].id;
+      //       originType = data[i].type;
+      //     }
+
+      //     data[i]['originId'] = originId;
+      //     data[i]['originType'] = originType;
+      //     data[i]['parentId'] = data[i]['parentId'];
+      //     if (data[i].children && data[i].children.length > 0) {
+      //       this._setParentName(data[i].children);
+      //     }
+      //   }
+      //   return data;
+      // },
+
+      handleNodeClick(data, node) {
+        this.$emit('handleNodeClick', data, node);
+      },
+      // 设置默认高亮行
+      setCurrentKey(id) {
+        this.currentKey = id;
+        this.$refs.tree.setCurrentKey(this.currentKey);
+      },
+
+      // 获取树的选中状态
+      getSelectList() {
+        const selectList = this.$refs.tree.getCurrentNode();
+        return selectList;
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .tree-wrapper {
+    width: 100%;
+    height: 100%;
+    overflow: auto;
+
+    :deep(.el-tree) {
+      display: inline-block;
+      min-width: 100%;
+    }
+  }
+</style>

+ 1 - 1
src/views/salesServiceManagement/components/AssetsDialog.vue

@@ -148,7 +148,7 @@
     </el-form>
     <el-container class="assets-dialog">
       <el-aside width="200px" class="wrapper-assets">
-        <AssetTree ref="treeList" :treeIds="[6]" @handleNodeClick="handleNodeClick" />
+        <AssetTree ref="treeList" :treeIds="[]" itemType="5" @handleNodeClick="handleNodeClick" />
       </el-aside>
       <el-main>
         <el-table

+ 32 - 18
src/views/salesServiceManagement/components/assetTree.vue

@@ -17,7 +17,7 @@
 
 <script>
   import { getTreeByIds } from '@/api/classifyManage';
-
+  import { getProduceTreeByPid } from '@/api/saleManage/quotation';
   export default {
     props: {
       defaultProps: {
@@ -44,6 +44,10 @@
       nodeKey: {
         type: String,
         default: 'id'
+      },
+      itemType: {
+        type: String,
+        default: ''
       }
     },
     data() {
@@ -65,26 +69,36 @@
         return new Promise(async (resolve) => {
           try {
             this.treeLoading = true;
+            let data = {};
+            if (this.treeIds.length > 0) {
+              let res = await getTreeByIds({ ids: this.treeIds.join(',') });
+              data = res.data;
+            } else {
+              data = await getProduceTreeByPid(this.itemType);
+            }
 
-            const res = await getTreeByIds({ ids: this.treeIds.join(',') });
             this.treeLoading = false;
-            if (res?.code === '0') {
-              this.treeList = res.data;
-              this.$emit('setRootId', res.data[0]);
 
-              this.$nextTick(() => {
-                // 默认高亮第一级树节点
-                if (this.treeList[0]) {
-                  this.setCurrentKey(this.treeList[0]);
-                  this.current = this.treeList[0];
-                  // 默认点击加载数据
-                  // const firstNode = document.querySelector('.el-tree-node');
-                  // firstNode.click();
-                  resolve(this.current);
-                }
-              });
-              return this.treeList;
-            }
+            // this.treeList = res.data;
+            this.treeList = this.$util.toTreeData({
+              data: data || [],
+              idField: 'id',
+              parentIdField: 'parentId'
+            });
+            this.$emit('setRootId', data[0]);
+
+            this.$nextTick(() => {
+              // 默认高亮第一级树节点
+              if (this.treeList[0]) {
+                this.setCurrentKey(this.treeList[0]);
+                this.current = this.treeList[0];
+                // 默认点击加载数据
+                // const firstNode = document.querySelector('.el-tree-node');
+                // firstNode.click();
+                resolve(this.current);
+              }
+            });
+            return this.treeList;
           } catch (error) {
             console.log(error);
           }

+ 1 - 1
src/views/salesServiceManagement/components/sparePartsList.vue

@@ -239,7 +239,7 @@
       classType="1"
       :is-get-inventory-total="true"
       @changeParent="confirmChoose"
-      :ids="[6]"
+      :itemType="5"
       :isFirstRefreshTable="true"
     ></product-list>
     <!-- <applyForSpare ref="edit" :inlet="1" /> -->

+ 1 - 1
src/views/salesServiceManagement/workOrder/components/declarationDialog.vue

@@ -180,7 +180,6 @@
                     placeholder="选择结束时间"
                     format="yyyy-MM-dd HH:mm:ss"
                     value-format="yyyy-MM-dd HH:mm:ss"
-                    :picker-options="endTimePickerOptions"
                     @change="handleTimeChange"
                   ></el-date-picker>
                 </el-form-item>
@@ -418,6 +417,7 @@ export default {
         const endTime = new Date(this.addForm.endTime).getTime();
         if (startTime > endTime) {
           this.addForm.endTime = '';
+          this.$message.warning('结束时间不能小于开始时间')
           this.days = 0;
           this.hours = 0;
           this.minutes = 0;

+ 0 - 2
src/views/salesServiceManagement/workOrder/components/detailDialog.vue

@@ -180,7 +180,6 @@ export default {
         },
         async getDetail(row) {
             const res = await getSalesWorkOrderById(row.id)
-            console.log(res, '工单的申请备品备件清单')
 
             res?.sparePartsApplyVO.map((item) => {
                 item.repairCode = res.code;
@@ -190,7 +189,6 @@ export default {
                     ...item
                 }
             })
-            console.log(res?.sparePartsApplyVO, '备品备件清单')
             this.detailList = res.sparePartsApplyVO || [];
             //需求单信息
             await this.getContactDetail(res?.afterSalesDemandVO.contactId);

+ 0 - 1
src/views/salesServiceManagement/workOrder/components/planDialog.vue

@@ -88,7 +88,6 @@ export default {
   },
   methods:{
     async init(data){
-      console.log(data,'data')
         this.dataForm = data;
     }
   }

+ 0 - 1
src/views/salesServiceManagement/workOrder/components/redeployOther2.vue

@@ -182,7 +182,6 @@ export default {
         this.$refs.tableRef2.toggleRowSelection(row.pop());
       }
       this.selectedRow = row[0];
-      console.log(this.selectedRow, 'selectedRowselectedRowselectedRow')
     },
     headerCellClassName({ columnIndex }) {
       // 如果是第一列(通常是全选框),则返回自定义的class名

+ 0 - 3
src/views/salesServiceManagement/workOrder/index.vue

@@ -441,9 +441,7 @@
       reload(where) {
         // 判断如果是选择的全部 不用传参
         if (this.orderStatus == 'all') {
-          console.log(this.orderStatus, 'this.orderStatus ====');
           // where = where ? delete where.orderStatus : '';
-          console.log(where, 'where');
           if (where) {
             delete where.orderStatus;
           }
@@ -455,7 +453,6 @@
         } else {
           where.orderStatus = this.orderStatus;
         }
-        console.log(where, 'where');
         this.$refs.table.reload({ page: 1, where });
       },
       async cancel(row) {