Răsfoiți Sursa

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

ysy 2 ani în urmă
părinte
comite
64965c2888

+ 54 - 0
src/api/ruleManagement/plan.js

@@ -68,6 +68,60 @@ export async function removeRule(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
+//仓库定义列表
+export async function getWarehouseList(params) {
+  const res = await request.post('/wms/warehouse/select/warehouseList', params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+}
+
+// 新增盘点计划
+export async function saveStocktakingPlan(params) {
+  const res = await request.post('/wms/planconfig/save', params);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 盘点计划列表
+export async function getInventoryList(data) {
+  let par = new URLSearchParams(data);
+  const res = await request.get('/wms/planconfig/page?' + par, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取盘点详情
+export async function getInventoryDetailById(id) {
+  const res = await request.get('/wms/planconfig/getById/' + id);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 修改盘点计划
+export async function updateStocktakingPlan(params) {
+  const res = await request.post('/wms/planconfig/update', params);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 盘点计划删除
+export async function deleteStocktakingPlan(data) {
+  const res = await request.delete(`/wms/planconfig/delete`, { data });
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
 // // 更新或保存
 // export async function saveOrUpdate (data) {
 //   const res = await request.post('/main/ruleinfo/saveOrEdit', data);

+ 10 - 5
src/components/CommomSelect/dept-select.vue

@@ -8,6 +8,7 @@
     value-key="id"
     default-expand-all
     ref="treeSelect"
+    :disabled="isBindPlan"
     :placeholder="placeholder"
     @input="updateValue"
     @change="changeChoose"
@@ -24,18 +25,22 @@
       placeholder: {
         type: String,
         default: '请选择'
+      },
+      isBindPlan: {
+        type: Boolean,
+        default: false
       }
     },
-    data () {
+    data() {
       return {
         treeData: []
       };
     },
-    created () {
+    created() {
       this.getData();
     },
     methods: {
-      async getData (params = {}) {
+      async getData(params = {}) {
         const data = await listOrganizations(params);
         this.treeData = this.$util.toTreeData({
           data: data || [],
@@ -44,11 +49,11 @@
         });
       },
       /* 更新选中数据 */
-      updateValue (value) {
+      updateValue(value) {
         this.$emit('input', value);
       },
 
-      changeChoose (val) {
+      changeChoose(val) {
         this.$emit(
           'changeGroup',
           val,

+ 219 - 0
src/components/selectTree/index.vue

@@ -0,0 +1,219 @@
+<template>
+  <el-select
+    filterable
+    ref="test"
+    :size="size"
+    :disabled="isBindPlan"
+    :value="valueTitle"
+    :clearable="clearable"
+    @clear="clearHandle"
+    :placeholder="placeholder"
+  >
+    <el-option :value="valueTitle" :label="valueTitle" class="options">
+      <slot :pHandleNodeClick="handleNodeClick">
+        <el-tree
+          id="tree-option"
+          ref="selectTree"
+          :key="treeKey"
+          :accordion="accordion"
+          :data="options"
+          :props="props"
+          :node-key="props.value"
+          :default-expand-all="isAll"
+          :default-expanded-keys="defaultExpandedKey"
+          @node-click="handleNodeClick"
+        >
+        </el-tree>
+      </slot>
+    </el-option>
+  </el-select>
+</template>
+
+<script>
+  export default {
+    props: {
+      // 配置项
+      props: {
+        type: Object,
+        default() {
+          return {
+            value: 'value', // ID字段名
+            label: 'label', // 显示名称
+            children: 'children' // 子级字段名
+          };
+        }
+      },
+      // 展开可不展开
+      isAll: { type: Boolean, default: true },
+      // 选项列表数据(树形结构的对象数组)
+      options: { type: Array, default: () => [] },
+      // 初始值
+      value: { type: [String, Number], default: null },
+      // 可清空选项
+      clearable: { type: Boolean, default: false },
+      // 自动收起
+      accordion: { type: Boolean, default: false },
+      // // 可清空选项
+      // disabled: { type: Boolean, default: false },
+      // 多选
+      multiple: { type: Boolean, default: false },
+      //
+
+      placeholder: {
+        type: String,
+        default: '请选择'
+      },
+      size: {
+        type: String,
+        default: 'mini'
+      },
+      dialogType: {
+        type: String,
+        default: ''
+      },
+      tableIndex: { type: Number, default: null },
+      initStr: {
+        type: String,
+        default: ''
+      },
+      isBindPlan: {
+        type: Boolean,
+        default: function () {
+          return false;
+        }
+      }
+    },
+    data() {
+      return {
+        valueId: null,
+        treeKey: true,
+        valueTitle: '',
+        defaultExpandedKey: []
+      };
+    },
+    watch: {
+      // 这个需要用深度监听,不然回显有时会失效
+      value: {
+        handler(val) {
+          this.valueId = this.value;
+          this.initHandle();
+        },
+        deep: true,
+        immediate: true
+      },
+      options: {
+        handler(val) {
+          this.initHandle();
+        },
+        deep: true,
+        immediate: true
+      },
+      initStr: {
+        handler(newVal, oldVal) {
+          if (this.initStr) {
+            // console.log(newVal);
+            this.valueTitle = newVal;
+          }
+        },
+        immediate: true
+      }
+    },
+    // mounted() {
+    //   this.valueId = this.value; // 初始值
+    //   setTimeout(() => {
+    //     this.initHandle();
+    //   },300)
+    // },
+    methods: {
+      // 初始化值
+      async initHandle() {
+        if (this.valueId) {
+          this.$nextTick(async () => {
+            const tempValue = await this.$refs.selectTree.getNode(this.valueId);
+            setTimeout(() => {
+              if (tempValue) {
+                this.valueTitle = tempValue.data[this.props.label]; // 初始化显示
+                this.$refs.selectTree.setCurrentKey(this.valueId); // 设置默认选中
+                this.defaultExpandedKey = [this.valueId]; // 设置默认展开
+              }
+            }, 300);
+          });
+        } else {
+          this.valueTitle = '';
+        }
+        this.initScroll();
+      },
+      // 初始化滚动条
+      initScroll() {
+        this.$nextTick(() => {
+          let scrollWrap = document.querySelectorAll(
+            '.el-scrollbar .el-select-dropdown__wrap'
+          )[0];
+          let scrollBar = document.querySelectorAll(
+            '.el-scrollbar .el-scrollbar__bar'
+          );
+          scrollWrap.style.cssText =
+            'margin: 0px; max-height: none; overflow: hidden;';
+          scrollBar.forEach((ele) => (ele.style.width = 0));
+        });
+      },
+      // 切换选项
+      handleNodeClick(node) {
+        // 多选
+        if (this.multiple) {
+          this.valueTitle += `${node[this.props.label]} , `;
+          this.valueId = node[this.props.value];
+          this.$emit('getValue', node);
+          this.defaultExpandedKey = [];
+          return;
+        }
+        this.valueTitle = node[this.props.label];
+        this.valueId = node[this.props.value];
+        this.$emit('getValue', node);
+        this.defaultExpandedKey = [];
+        this.$refs.test.handleClose();
+      },
+      // 清除选中
+      clearHandle() {
+        this.valueTitle = '';
+        this.valueId = null;
+        this.defaultExpandedKey = [];
+        // this.clearSelected()
+        this.treeKey = !this.treeKey;
+        this.$emit('getValue', null);
+      },
+      // 清空选中样式
+      clearSelected() {
+        let allNode = document.querySelectorAll('#tree-option .el-tree-node');
+        allNode.forEach((element) => element.classList.remove('is-current'));
+      }
+    }
+  };
+</script>
+<style scoped>
+  .el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
+    height: auto;
+    max-height: 274px;
+    padding: 0;
+    overflow: hidden;
+    overflow-y: auto;
+  }
+  .el-select-dropdown__item.selected {
+    font-weight: normal;
+  }
+  ul li >>> .el-tree .el-tree-node__content {
+    height: auto;
+    padding: 0 20px;
+  }
+  .el-tree-node__label {
+    font-weight: normal;
+  }
+  .el-tree >>> .is-current .el-tree-node__label {
+    color: #1890ff;
+    font-weight: 700;
+  }
+  .el-tree >>> .is-current .el-tree-node__children .el-tree-node__label {
+    color: #606266;
+    font-weight: normal;
+  }
+</style>

+ 5 - 0
src/utils/dict/rulesManagement.js

@@ -0,0 +1,5 @@
+// 盘点类型
+export const inventoryTypeStatus = [
+  { code: 1, label: '仓库内' },
+  { code: 2, label: '仓库外' }
+];

+ 10 - 9
src/views/bpm/model/components/modelSearch.vue

@@ -3,12 +3,12 @@
   <el-form
     label-width="100px"
     class="ele-form-search"
-    @keyup.enter.native="search"
+    @keyup.enter.native="search(true)"
     @submit.native.prevent
   >
     <el-row :gutter="15">
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="流程标识:" prop="key">
+        <el-form-item label="流程标识:" prop="queryParams.key">
           <el-input
             clearable
             v-model.trim="queryParams.key"
@@ -16,7 +16,7 @@
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="流程名称:" prop="name">
+        <el-form-item label="流程名称:" prop="queryParams.name">
           <el-input
             clearable
             v-model="queryParams.name"
@@ -29,7 +29,7 @@
             type="primary"
             icon="el-icon-search"
             class="ele-btn-icon"
-            @click="search"
+            @click="search(true)"
           >
             查询
           </el-button>
@@ -48,6 +48,7 @@
         name: ''
       };
       return {
+        defaultParams,
         // 表单数据
         queryParams: { ...defaultParams }
       };
@@ -60,15 +61,15 @@
     },
     methods: {
       /* 搜索 */
-      search () {
-        this.$emit('search', {
-          ...this.params
+      search (reset) {
+        this.$emit('search', {reset: reset,
+          ...this.queryParams
         });
       },
       /*  重置 */
       reset () {
-        this.params = { ...this.defaultParams };
-        this.search();
+        this.queryParams = { ...this.defaultParams };
+        this.search(true);
       }
     }
   };

+ 9 - 6
src/views/bpm/model/index.vue

@@ -224,23 +224,26 @@
     },
     methods: {
       /* 表格数据源 */
-      async datasource ({ page, limit }) {
+      async datasource ({ page, where, limit }) {
         return await getModelPage({
           pageNo: page,
           pageSize: limit,
-          ...this.listQuery
+          ...where
         });
       },
       /* 刷新表格 */
-      reload () {
-        this.$refs.table.reload({ page: 1 });
+      reload (params) {
+        if(params.reset){
+          this.$refs.table.reload({ page: 1, where: params });
+        } else {
+          this.$refs.table.reload({ where: params });
+        }
       },
+
       /** 取消按钮 */
       cancel() {
-       
         this.open = false;
       },
-      
 
       // 表单重置
       reset() {

+ 3 - 1
src/views/rulesManagement/components/MaterialAdd.vue

@@ -32,7 +32,7 @@
         <template v-slot:content>
           <ProductSearch @search="reload" ref="searchRef" />
           <ele-pro-table
-            style="min-height: 400px"
+            height="400"
             ref="table"
             :columns="columns"
             :datasource="datasource"
@@ -242,6 +242,8 @@
             > div {
               flex: 1;
               .ele-split-panel-body {
+                display: flex;
+                flex-direction: column;
                 > div {
                   height: 100%;
                   display: flex;

+ 1 - 1
src/views/rulesManagement/components/product-search.vue

@@ -23,7 +23,7 @@
           <el-input clearable v-model="where.fixCode" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { md: 4 } : { md: 4 }">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
         <div class="ele-form-actions">
           <el-button
             type="primary"

+ 26 - 11
src/views/rulesManagement/components/programRulesDialog.vue

@@ -648,10 +648,10 @@
       save() {
         console.log(this.addForm);
         console.log(this.ruleIdList);
-        this.$refs.addFormRef.validate(async (valid) => {
-          console.log(valid);
-          if (valid) {
-            try {
+        if (this.ruleIdList && this.ruleIdList.length > 0) {
+          this.$refs.addFormRef.validate(async (valid) => {
+            console.log(valid);
+            if (valid) {
               //   this.addForm.deviceInfo = selectList.map((item) => {
               //     return {
               //       substanceId: item.id,
@@ -689,6 +689,14 @@
                   ruleMatters: item.ruleItems
                 };
               });
+              console.log(planConfigAddOrUpdatePOList);
+              let boolen = planConfigAddOrUpdatePOList.every(
+                (item) => item.deviceInfo.length > 0
+              );
+              if (!boolen) {
+                this.$message.error('请添加设备!');
+                return false;
+              }
               this.addForm.ruleName = this.ruleIdList
                 .map((item) => item.name)
                 .join(',');
@@ -700,14 +708,21 @@
               this.addForm.ruleId = '0'; // 无效后台验证
               let sendMsg = deepClone(this.addForm);
               const type = this.dialogTitle.includes('新增') ? '新增' : '编辑';
-              let res = await saveOrUpdate(sendMsg);
-              if (res) {
-                this.$message.success(type + '成功!');
-                this.$emit('done');
+              try {
+                let res = await saveOrUpdate(sendMsg);
+                if (res) {
+                  this.$message.success(type + '成功!');
+                  this.$emit('done');
+                }
+              } catch (error) {
+                console.log(error);
+                this.$message.error(type + '失败!');
               }
-            } catch (error) {}
-          }
-        });
+            }
+          });
+        } else {
+          this.$message.error('请添加规则!');
+        }
       },
       // 保存操作指导数据
       saveEdit(data, index) {

+ 24 - 19
src/views/rulesManagement/matterRules/components/matter-add.vue

@@ -402,8 +402,9 @@
       // 保存
       dataKeep() {
         let form = deepClone(this.formData);
-        console.log(form);
+        console.log(this.$refs.cycleMultipleRef);
         form.cycle = this.$refs.cycleMultipleRef.ruleCycleList;
+        console.log(form);
         switch (form.cycleType) {
           case 1:
             if (form.cycle[0].minute === '') {
@@ -475,25 +476,29 @@
             }
             break;
         }
-        this.$refs.contentConfigForm.validate(async (valid) => {
-          if (valid) {
-            // let form = deepClone(this.formData)
-            // form.ruleCycleList = this.$refs.cycleMultipleRef.ruleCycleList
-            // form.ruleItems.forEach(item => {
-            //   if (item.ruleType) {
-            //     item.ruleType = this.ruleTypeObj[item.ruleType.code]
-            //   }
-            // })
-            let res = await saveOrUpdate(form);
-            if (res) {
-              this.$message.success('操作成功!');
-              this.handleClose();
-              this.$emit('done');
+        if (form.ruleItems && form.ruleItems.length > 0) {
+          this.$refs.contentConfigForm.validate(async (valid) => {
+            if (valid) {
+              // let form = deepClone(this.formData)
+              // form.ruleCycleList = this.$refs.cycleMultipleRef.ruleCycleList
+              // form.ruleItems.forEach(item => {
+              //   if (item.ruleType) {
+              //     item.ruleType = this.ruleTypeObj[item.ruleType.code]
+              //   }
+              // })
+              let res = await saveOrUpdate(form);
+              if (res) {
+                this.$message.success('操作成功!');
+                this.handleClose();
+                this.$emit('done');
+              }
+            } else {
+              this.$message.warning('请将信息补充完整!');
             }
-          } else {
-            this.$message.warning('请将信息补充完整!');
-          }
-        });
+          });
+        } else {
+          this.$message.error('请添加事项内容!');
+        }
       }
     }
   };

+ 2 - 1
src/views/rulesManagement/matterRules/components/operationGuideDialog.vue

@@ -113,6 +113,7 @@
 </template>
 
 <script>
+  import { deepClone } from '@/utils';
   // import { update, getById } from '@/api/inspectionClassify';
   import ProductModal from './ProductModal.vue';
   export default {
@@ -155,7 +156,7 @@
         console.log(row);
         console.log(index);
         if (row) {
-          this.form = row;
+          this.form = deepClone(row);
         }
         this.currentIndex = index;
         this.visible = true;

+ 190 - 176
src/views/rulesManagement/matterRules/components/rule-cycle.vue

@@ -4,7 +4,8 @@
       <el-col :span="2">
         <el-input
           @input="
-            value => (formData.cycleValue = value.replace(/^(0+)|[^\d]+/g, ''))
+            (value) =>
+              (formData.cycleValue = value.replace(/^(0+)|[^\d]+/g, ''))
           "
           class="cycle_value"
           size="small"
@@ -40,7 +41,7 @@
             v-model.number="item.month"
             size="small"
             oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
-            @input="e => inputMonth(e, index)"
+            @input="(e) => inputMonth(e, index)"
             v-if="[5].includes(formData.cycleType)"
             :disabled="isBindPlan"
           >
@@ -51,7 +52,7 @@
             v-model.number="item.day"
             size="small"
             oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
-            @input="e => inputDay(e, index)"
+            @input="(e) => inputDay(e, index)"
             v-if="[4, 5].includes(formData.cycleType)"
             :disabled="isBindPlan"
           >
@@ -62,7 +63,7 @@
             v-model.number="item.hour"
             size="small"
             oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-            @input="e => inputHour(e, index)"
+            @input="(e) => inputHour(e, index)"
             v-if="[2, 4, 5].includes(formData.cycleType)"
             :disabled="isBindPlan"
           >
@@ -73,7 +74,7 @@
             v-model.number="item.minute"
             size="small"
             oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-            @input="e => inputMinute(e, index)"
+            @input="(e) => inputMinute(e, index)"
             :disabled="isBindPlan"
           >
             <template #suffix>分</template>
@@ -118,7 +119,7 @@
               size="small"
               placeholder="时"
               oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-              @input="e => inputHour(e, index)"
+              @input="(e) => inputHour(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>时</template>
@@ -130,7 +131,7 @@
               v-model.number="item.minute"
               size="small"
               oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-              @input="e => inputMinute(e, index)"
+              @input="(e) => inputMinute(e, index)"
               placeholder="分"
               :disabled="isBindPlan"
             >
@@ -152,7 +153,12 @@
         >
           <span>第{{ index + 1 }}次</span>
           <div class="cycle_sub_item" v-if="pageType">
-            <el-select v-model.number="item.week" size="small" placeholder="周" :disabled="isBindPlan">
+            <el-select
+              v-model.number="item.week"
+              size="small"
+              placeholder="周"
+              :disabled="isBindPlan"
+            >
               <el-option
                 v-for="item in weekList"
                 :key="item.value"
@@ -168,7 +174,7 @@
               size="small"
               placeholder="时"
               oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-              @input="e => inputHour(e, index)"
+              @input="(e) => inputHour(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>时</template>
@@ -192,7 +198,7 @@
               size="small"
               placeholder="日"
               oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
-              @input="e => inputDay(e, index)"
+              @input="(e) => inputDay(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>日</template>
@@ -205,7 +211,7 @@
               size="small"
               placeholder="时"
               oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-              @input="e => inputHour(e, index)"
+              @input="(e) => inputHour(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>时</template>
@@ -229,7 +235,7 @@
               size="small"
               placeholder="月"
               oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
-              @input="e => inputMonth(e, index)"
+              @input="(e) => inputMonth(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>月</template>
@@ -242,7 +248,7 @@
               size="small"
               placeholder="日"
               oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
-              @input="e => inputDay(e, index)"
+              @input="(e) => inputDay(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>日</template>
@@ -255,7 +261,7 @@
               size="small"
               placeholder="时"
               oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
-              @input="e => inputHour(e, index)"
+              @input="(e) => inputHour(e, index)"
               :disabled="isBindPlan"
             >
               <template #suffix>时</template>
@@ -269,189 +275,197 @@
 </template>
 
 <script>
-export default {
-  props: {
-    formData: {
-      type: Object,
-      default: () => {
-        return {}
+  export default {
+    props: {
+      formData: {
+        type: Object,
+        default: () => {
+          return {};
+        }
+      },
+      // 编辑edit和新增add
+      pageType: {
+        type: String,
+        default: ''
+      },
+
+      isBindPlan: {
+        type: Boolean,
+        default: () => {
+          return false;
+        }
       }
     },
-    // 编辑edit和新增add
-    pageType: {
-      type: String,
-      default: ''
+    data() {
+      return {
+        ruleCycleList: [
+          // {
+          //   year: '', // 周期年
+          //   month: '', // 周期月
+          //   week: '', // 周期周
+          //   day: '', // 周期日
+          //   hour: '', // 周期时
+          //   minute: '', // 周期分
+          //   second: '' // 周期秒
+          // }
+        ],
+        weekList: [
+          { value: 1, label: '周一' },
+          { value: 2, label: '周二' },
+          { value: 3, label: '周三' },
+          { value: 4, label: '周四' },
+          { value: 5, label: '周五' },
+          { value: 6, label: '周六' },
+          { value: 7, label: '周日' }
+        ],
+        cycleOptObj: {
+          1: '时/次',
+          2: '天/次',
+          //3: '周/次',
+          4: '月/次',
+          5: '年/次',
+          11: '次/天',
+          //12: '次/周',
+          13: '次/月',
+          14: '次/年'
+        },
+        cycleOpt: [
+          { code: 1, label: '时/次' },
+          { code: 2, label: '天/次' },
+          //{ code: 3, label: '周/次' },
+          { code: 4, label: '月/次' },
+          { code: 5, label: '年/次' },
+          { code: 11, label: '次/天' },
+          //{ code: 12, label: '次/周' },
+          { code: 13, label: '次/月' },
+          { code: 14, label: '次/年' }
+        ]
+      };
     },
-
-    isBindPlan:{
-      type: Boolean,
-      default: () => {
-        return false
-      }
-    }
-  },
-  data () {
-    return {
-      ruleCycleList: [
-        // {
-        //   year: '', // 周期年
-        //   month: '', // 周期月
-        //   week: '', // 周期周
-        //   day: '', // 周期日
-        //   hour: '', // 周期时
-        //   minute: '', // 周期分
-        //   second: '' // 周期秒
-        // }
-      ],
-      weekList: [
-        { value: 1, label: '周一' },
-        { value: 2, label: '周二' },
-        { value: 3, label: '周三' },
-        { value: 4, label: '周四' },
-        { value: 5, label: '周五' },
-        { value: 6, label: '周六' },
-        { value: 7, label: '周日' }
-      ],
-      cycleOptObj: {
-        1: '时/次',
-        2: '天/次',
-        //3: '周/次',
-        4: '月/次',
-        5: '年/次',
-        11: '次/天',
-        //12: '次/周',
-        13: '次/月',
-        14: '次/年'
-      },
-      cycleOpt: [
-        { code: 1, label: '时/次' },
-        { code: 2, label: '天/次' },
-        //{ code: 3, label: '周/次' },
-        { code: 4, label: '月/次' },
-        { code: 5, label: '年/次' },
-        { code: 11, label: '次/天' },
-        //{ code: 12, label: '次/周' },
-        { code: 13, label: '次/月' },
-        { code: 14, label: '次/年' }
-      ]
-    }
-  },
-  watch: {
-    formData (val) {
-      this.ruleCycleList = val.cycle
-    }
-  },
-  methods: {
-    // 巡点检周期输入数量
-    cycleValueChange (val) {
-      console.log(val)
-      const cycleType01 = [1, 2, 4, 5]
-      const cycleType02 = [11, 13, 14]
-      this.ruleCycleList = []
-
-      // 次在后
-      if (cycleType01.includes(this.formData.cycleType)) {
-        this.ruleCycleList.push({
-          month: 1, // 周期月
-          day: 1, // 周期日
-          hour: 0, // 周期时
-          minute: 0 // 周期分
-        })
+    watch: {
+      formData(val) {
+        console.log(val.cycle);
+        if (val.cycle) {
+          this.ruleCycleList = val.cycle;
+        }
       }
+    },
+    methods: {
+      // 巡点检周期输入数量
+      cycleValueChange(val) {
+        console.log(val);
+        console.log(this.formData.cycleType);
+        const cycleType01 = [1, 2, 4, 5];
+        const cycleType02 = [11, 13, 14];
+        this.ruleCycleList = [];
 
-      // 次在前
-      if (cycleType02.includes(this.formData.cycleType)) {
-        for (let i = 0; i < val; i++) {
+        // 次在后
+        console.log(cycleType01.includes(this.formData.cycleType));
+        if (cycleType01.includes(this.formData.cycleType)) {
           this.ruleCycleList.push({
             month: 1, // 周期月
             day: 1, // 周期日
             hour: 0, // 周期时
             minute: 0 // 周期分
-          })
+          });
+          console.log(this.ruleCycleList);
         }
-      }
 
-      // 时/次
-      if (this.formData.cycleType === 1) {
-        this.ruleCycleList.forEach(item => {
-          delete item.month
-          delete item.day
-          delete item.hour
-        })
-      }
-      // 天/次、次/天
-      if ([2, 11].includes(this.formData.cycleType)) {
-        this.ruleCycleList.forEach(item => {
-          delete item.month
-          delete item.day
-        })
-      }
-      // 月/次、次/月
-      if ([4, 13].includes(this.formData.cycleType)) {
-        this.ruleCycleList.forEach(item => {
-          delete item.month
-        })
-      }
-    },
+        // 次在前
+        if (cycleType02.includes(this.formData.cycleType)) {
+          for (let i = 0; i < val; i++) {
+            this.ruleCycleList.push({
+              month: 1, // 周期月
+              day: 1, // 周期日
+              hour: 0, // 周期时
+              minute: 0 // 周期分
+            });
+          }
+        }
 
-    // 周期类型选择
-    handleCycleTypeChange () {
-      this.cycleValueChange(this.formData.cycleValue)
-    },
+        // 时/次
+        if (this.formData.cycleType === 1) {
+          this.ruleCycleList.forEach((item) => {
+            delete item.month;
+            delete item.day;
+            delete item.hour;
+          });
+        }
 
-    // 输入月
-    inputMonth (e, index) {
-      if (e > 12) {
-        this.ruleCycleList[index].month = 1
-        return this.$message.warning('月份最大值为12月')
-      }
-    },
-    // 输入日
-    inputDay (e, index) {
-      if (e > 31) {
-        this.ruleCycleList[index].day = 1
-        return this.$message.warning('日期最大值为31日')
-      }
-    },
-    // 输入时
-    inputHour (e, index) {
-      if (e > 23) {
-        this.ruleCycleList[index].hour = 0
-        return this.$message.warning('时间最大值为23时')
-      }
-    },
-    // 输入时
-    inputMinute (e, index) {
-      if (e > 59) {
-        this.ruleCycleList[index].minute = 0
-        return this.$message.warning('分钟最大值为59分')
+        console.log(this.ruleCycleList);
+        // 天/次、次/天
+        if ([2, 11].includes(this.formData.cycleType)) {
+          this.ruleCycleList.forEach((item) => {
+            delete item.month;
+            delete item.day;
+          });
+        }
+        // 月/次、次/月
+        if ([4, 13].includes(this.formData.cycleType)) {
+          this.ruleCycleList.forEach((item) => {
+            delete item.month;
+          });
+        }
+      },
+
+      // 周期类型选择
+      handleCycleTypeChange() {
+        this.cycleValueChange(this.formData.cycleValue);
+      },
+
+      // 输入月
+      inputMonth(e, index) {
+        if (e > 12) {
+          this.ruleCycleList[index].month = 1;
+          return this.$message.warning('月份最大值为12月');
+        }
+      },
+      // 输入日
+      inputDay(e, index) {
+        if (e > 31) {
+          this.ruleCycleList[index].day = 1;
+          return this.$message.warning('日期最大值为31日');
+        }
+      },
+      // 输入时
+      inputHour(e, index) {
+        if (e > 23) {
+          this.ruleCycleList[index].hour = 0;
+          return this.$message.warning('时间最大值为23时');
+        }
+      },
+      // 输入时
+      inputMinute(e, index) {
+        if (e > 59) {
+          this.ruleCycleList[index].minute = 0;
+          return this.$message.warning('分钟最大值为59分');
+        }
       }
     }
-  }
-}
+  };
 </script>
 
 <style lang="scss" scoped>
-.cycle_item {
-  display: flex;
-  align-items: center;
-  color: #666;
-  > span {
-    width: 50px;
-  }
-  .cycle_sub_item {
-    flex: 1;
+  .cycle_item {
     display: flex;
     align-items: center;
+    color: #666;
+    > span {
+      width: 50px;
+    }
+    .cycle_sub_item {
+      flex: 1;
+      display: flex;
+      align-items: center;
+    }
+  }
+  .cycle01_box {
+    display: flex;
+    ::v-deep .el-input {
+      width: 80px;
+    }
   }
-}
-.cycle01_box {
-  display: flex;
-  ::v-deep .el-input {
-    width: 80px;
+  .cycle_time_column {
+    display: flex;
   }
-}
-.cycle_time_column {
-  display: flex;
-}
 </style>

+ 748 - 391
src/views/rulesManagement/planRules/components/addInventoryDialog.vue

@@ -16,35 +16,35 @@
       label-width="110px"
     >
       <el-row :gutter="20">
-       <el-col :span="8">
+        <el-col :span="8">
           <el-form-item label="计划配置单号" prop="code">
             <el-input
-              v-model="addForm.code"
+              v-model="addForm.planCode"
               placeholder="自动生成"
               disabled
             ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="计划配置名称" prop="planRuleName">
+          <el-form-item label="计划配置名称" prop="planName">
             <el-input
-              v-model="addForm.planRuleName"
+              v-model="addForm.planName"
               placeholder="请输入"
-               :disabled="isBindPlan"
+              :disabled="isBindPlan"
             ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="自动派单" prop="isSyncBill">
+          <el-form-item label="自动派单" prop="autoOrder">
             <el-select
-              v-model="addForm.isSyncBill"
+              v-model="addForm.autoOrder"
               class="w100"
               placeholder="请选择"
-               :disabled="isBindPlan"
-			   filterable
+              :disabled="isBindPlan"
+              filterable
             >
-              <el-option :value="true" label="是"></el-option>
-              <el-option :value="false" label="否"></el-option>
+              <el-option :value="1" label="是"></el-option>
+              <el-option :value="0" label="否"></el-option>
             </el-select>
           </el-form-item>
         </el-col>
@@ -54,8 +54,9 @@
               v-model="addForm.ruleId"
               class="w100"
               placeholder="请选择规则名称"
-               :disabled="isBindPlan"
-			  filterable
+              @change="change_ruleId"
+              :disabled="isBindPlan"
+              filterable
             >
               <el-option
                 v-for="item in ruleNameList"
@@ -68,17 +69,17 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="盘点类型" prop="bizType">
+          <el-form-item label="盘点类型" prop="inventoryType">
             <el-select
-              v-model="addForm.bizType"
+              v-model="addForm.inventoryType"
               class="w100"
               placeholder="请选择"
               @change="chooseType"
-               :disabled="isBindPlan"
-			  filterable
+              :disabled="isBindPlan"
+              filterable
             >
               <el-option
-                v-for="item in wh_checkStatus"
+                v-for="item in inventoryTypeStatus"
                 :key="item.code"
                 :value="item.code"
                 :label="item.label"
@@ -86,27 +87,93 @@
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
-          <el-form-item
-            label="盘点仓库"
-            :rules="
-              addForm.bizType == 1
-                ? [
-                    {
-                      required: true,
-                      message: '请选择资产类别',
-                      trigger: ['blur', 'change']
-                    }
-                  ]
-                : []
-            "
-          >
+        <el-col v-if="addForm.inventoryType == 2" :span="8">
+          <el-form-item label="所属厂房:" prop="plantId">
+            <el-select
+              v-model="addForm.plantId"
+              :disabled="isBindPlan"
+              placeholder="请选择"
+              @change="change_factoryId"
+              style="width: 100%"
+            >
+              <el-option
+                v-for="item in factoryOptions"
+                :key="item.id"
+                :label="item.pathName"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col v-if="addForm.inventoryType == 2" :span="8">
+          <el-form-item label="所属车间:" prop="workshopId">
+            <el-select
+              v-model="addForm.workshopId"
+              :disabled="isBindPlan"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_workshop"
+            >
+              <el-option
+                v-for="item in workshopOptions"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col v-if="addForm.inventoryType == 2" :span="8">
+          <el-form-item label="所属产线:" prop="productionLineId">
+            <el-select
+              v-model="addForm.productionLineId"
+              :disabled="isBindPlan"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_productionLineId"
+            >
+              <el-option
+                v-for="item in productionLineOptions"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col v-if="addForm.inventoryType == 2" :span="8">
+          <el-form-item label="所属工位:" prop="stationId">
+            <el-select
+              v-model="addForm.stationId"
+              :disabled="isBindPlan"
+              placeholder="请选择"
+              style="width: 100%"
+              @change="change_stationId"
+            >
+              <el-option
+                v-for="item in stationOptions"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col v-if="addForm.inventoryType == 1" :span="8">
+          <el-form-item label="盘点仓库" prop="warehouseId">
             <el-select
               placeholder="请选择"
               class="w100"
-              v-model="addForm.bizTypeId"
-              :disabled="addForm.bizType == 2||isBindPlan"
-			  filterable
+              v-model="addForm.warehouseId"
+              @change="changeWarehouse"
+              :disabled="addForm.inventoryType == 2 || isBindPlan"
+              filterable
             >
               <el-option
                 v-for="item in warehouseList"
@@ -115,93 +182,131 @@
                 :label="item.name"
                 @click.native="
                   () => {
-                    addForm.bizTypeName = item.name
+                    addForm.bizTypeName = item.name;
                   }
                 "
               ></el-option>
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <!-- <el-col :span="8">
           <el-form-item label="审核人" prop="verifyUserId">
             <el-select
               v-model="addForm.verifyUserId"
               size="small"
               style="width: 100%"
-               :disabled="isBindPlan"
-			   filterable
+              :disabled="isBindPlan"
+              filterable
             >
-			  <el-option
-			    v-for="item in uerList"
-			    :key="item.id"
-			    :value="item.id"
-			    :label="item.name"
-			  ></el-option>
+              <el-option
+                v-for="item in uerList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
             </el-select>
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="8">
           <el-form-item label="计划盘点时长" prop="duration">
-            <el-input v-model.number="addForm.duration" placeholder="请输入" :disabled="isBindPlan">
+            <el-input
+              v-model.number="addForm.duration"
+              placeholder="请输入"
+              :disabled="isBindPlan"
+            >
               <template #suffix>分钟</template>
             </el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="资产分类" prop="assetDict">
-            <DictSelection dictName="类型用途" clearable filterable v-model="addForm.assetDict">
-            </DictSelection>
+          <el-form-item label="分类" prop="categoryLevelId">
+            <!-- <DictSelection
+              dictName="类型用途"
+              clearable
+              filterable
+              v-model="addForm.categoryLevelId"
+            >
+            </DictSelection> -->
+            <selectTree
+              :isBindPlan="isBindPlan"
+              ref="tree"
+              class="form-ipt"
+              size="medium"
+              style="width: 100%"
+              :value="addForm.categoryLevelId"
+              clearable
+              :options="codeList"
+              :props="{
+                value: 'id',
+                label: 'name',
+                children: 'children'
+              }"
+              @getValue="codeListValue"
+              :isAll="false"
+            />
           </el-form-item>
         </el-col>
-        <el-col :span="8" v-if="addForm.isSyncBill">
-          <el-form-item label="执行部门" prop="executorDeptCode">
-				    <deptSelect v-model="addForm.executorDeptCode" @changeGroup="searchDeptNodeClick"/>
+        <el-col :span="8">
+          <el-form-item label="紧急程度" prop="urgent">
+            <DictSelection
+              :disabled="isBindPlan"
+              dictName="紧急程度"
+              clearable
+              filterable
+              v-model="addForm.urgent"
+            >
+            </DictSelection>
           </el-form-item>
         </el-col>
-        <el-col :span="8" v-if="addForm.isSyncBill">
-          <el-form-item label="执行人员" prop="executorId">
-			  <el-select
-			    v-model="addForm.executorId"
-			    size="small"
-			    style="width: 100%"
-			    :disabled="isBindPlan"
-				filterable
-			  >
-			    <el-option
-			      v-for="item in executorList"
-			      :key="item.id"
-			      :value="item.id"
-			      :label="item.name"
-			    ></el-option>
-			  </el-select>
+        <el-col :span="8" v-if="addForm.autoOrder">
+          <el-form-item label="执行部门" prop="executeGroupId">
+            <deptSelect
+              :isBindPlan="isBindPlan"
+              v-model="addForm.executeGroupId"
+              @changeGroup="searchDeptNodeClick"
+            />
           </el-form-item>
         </el-col>
-        <el-col :span="8">
-          <el-form-item label="紧急程度" prop="urgent">
-			  <DictSelection dictName="紧急程度" clearable filterable v-model="addForm.urgent">
-			  </DictSelection>
+        <el-col :span="8" v-if="addForm.autoOrder">
+          <el-form-item label="执行人员" prop="executorId">
+            <el-select
+              v-model="addForm.executorId"
+              @change="changeExecutor"
+              :disabled="isBindPlan"
+              size="small"
+              style="width: 100%"
+              filterable
+            >
+              <el-option
+                v-for="item in executorList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <el-col v-if="addForm.inventoryType == 1" :span="8">
           <el-form-item label="锁库盘点" prop="isTreasuryLock">
             <el-switch
-              v-model="addForm.isTreasuryLock"
+              v-model="addForm.lockWarehouse"
               active-text="开"
               inactive-text="关"
               :active-value="1"
               :inactive-value="0"
-               :disabled="isBindPlan"
+              :disabled="isBindPlan"
             ></el-switch>
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item label="状态" prop="status">
+          <el-form-item label="状态" prop="enable">
             <el-switch
-              v-model="addForm.status"
+              v-model="addForm.enable"
+              :disabled="isBindPlan"
               active-text="开"
               inactive-text="关"
-              :active-value="true"
-              :inactive-value="false"
+              :active-value="1"
+              :inactive-value="0"
             ></el-switch>
           </el-form-item>
         </el-col>
@@ -213,7 +318,7 @@
               :rows="2"
               resize="none"
               v-model="addForm.remark"
-               :disabled="isBindPlan"
+              :disabled="isBindPlan"
             ></el-input>
           </el-form-item>
         </el-col>
@@ -238,343 +343,595 @@
         :assetsName="addForm.assetsName"
         :warehouseId="addForm.bizTypeId"
         :assetsType="assetsType"
-        :bizType="addForm.bizType"
+        :bizType="addForm.inventoryType"
         :planRuleInventoryDetailList="planRuleInventoryDetailList"
-        :isBindPlan = "isBindPlan"
+        :isBindPlan="isBindPlan"
       />
     </el-form>
-    <div slot="footer">
+    <div v-if="!isBindPlan" slot="footer">
       <el-button type="primary" size="small" @click="submit">提交</el-button>
       <el-button size="small" @click="handleClose">关闭</el-button>
     </div>
+    <div v-else slot="footer">
+      <el-button type="primary" size="small" @click="dialogVisible = false"
+        >确定</el-button
+      >
+      <el-button size="small" @click="dialogVisible = false">关闭</el-button>
+    </div>
   </el-dialog>
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
-// import { wh_checkStatus} from '@/utils/dict/warehouse'
-import { getCode , getWarehouseList } from '@/api/ruleManagement/matter';
-import AssetsInWarehouse from './AssetsInWarehouse'
-import { getRule } from '@/api/ruleManagement/plan'
-import {  getUserPage } from '@/api/system/organization';
-import deptSelect from '@/components/CommomSelect/dept-select.vue'
-export default {
-  props: {
-    dialogTile: {
-      type: String,
-      default: '新增盘点计划配置'
-    },
-    isBindPlan: {
-      type: Boolean,
-      default: function () {
-        return false
-      }
-    },
-  },
-  components: { 
-	deptSelect,
-    AssetsInWarehouse 
-  },
-  data () {
-    return {
-	  addDialogLoading:false,
-      dialogVisible: false,
-      wh_checkStatus:[], // 盘点类型
-      warehouseList: [], // 盘点仓库
-      uerList: [], // 审核人
-      executorList: [], // 执行人
-      assetsType: null,
-      planRuleInventoryDetailList: [],
-      addForm: {
-        code: '', // 计划配置单号
-        planRuleName: '', // 计划配置名称
-        isSyncBill: true, // 是否自动派单
-        ruleId: '', // 规则名称
-        bizType: '', // 盘点类型
-        bizTypeId: '', // 盘点仓库Id
-        bizTypeName: '', // 盘点仓库name
-        verifyUserId: '', // 审核人Id
-        verifyUserName: '', // 审核人name
-        duration: null, // 盘点时长
-        assetDict: '', // 资产分类id
-        assetsName: '', // 资产分类name
-        urgent: null, // 紧急程度
-        executorDeptCode: '', // 执行部门code
-        executorDeptName: '', // 执行部门name
-        executorId: '', // 执行人id
-        executorName: '', // 执行人name
-        isTreasuryLock: false, // 是否锁库盘点
-        status: true, // 状态
-        remark: '' // 备注
+  import { getFactoryarea } from '@/api/factoryModel';
+  import { listWorkshopByParentId, listFactoryLine } from '@/api/factoryModel';
+  import { listByProductionLineId } from '@/api/workforceManagement/team';
+  import selectTree from '@/components/selectTree';
+  import { getTreeByGroup } from '@/api/classifyManage';
+  import { inventoryTypeStatus } from '@/utils/dict/rulesManagement';
+  import { mapGetters } from 'vuex';
+  // import { wh_checkStatus} from '@/utils/dict/warehouse'
+  import { getCode } from '@/api/ruleManagement/matter';
+  import AssetsInWarehouse from './AssetsInWarehouse';
+  import {
+    getRule,
+    getWarehouseList,
+    saveStocktakingPlan,
+    updateStocktakingPlan,
+    getInventoryDetailById
+  } from '@/api/ruleManagement/plan';
+  import { getUserPage } from '@/api/system/organization';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  export default {
+    props: {
+      dialogTile: {
+        type: String,
+        default: '新增盘点计划配置'
       },
-      rules: {
-        planRuleName: [
-          { required: true, message: '请输入计划配置名称', trigger: 'blur' }
-        ],
-        isSyncBill: [
-          { required: true, message: '请选择是否自动派单', trigger: 'change' }
-        ],
-        ruleId: [
-          { required: true, message: '请选择规则名称', trigger: 'change' }
-        ],
-        duration: [
-          { required: true, message: '请输入计划完成时长', trigger: 'blur' }
-        ],
-        bizType: [
-          { required: true, message: '请选择盘点类型', trigger: 'change' }
-        ],
-        bizTypeId: [
-          { required: true, message: '请选择盘点仓库', trigger: 'change' }
-        ],
-        verifyUserId: [
-          { required: false, message: '请选择审核人', trigger: 'change' }
-        ],
-        executorDeptCode: [
-          { required: true, message: '请选择选择执行部门', trigger: 'change' }
-        ],
-        executorId: [
-          { required: true, message: '请选择选择执行人员', trigger: 'change' }
-        ],
-        assetDict: [
-          { required: true, message: '请选择资产分类', trigger: 'change' }
-        ]
+      isBindPlan: {
+        type: Boolean,
+        default: function () {
+          return false;
+        }
       },
-      ruleNameList:[],
-    }
-  },
-  watch: {
-    dialogVisible (val) {
-      if (val) {
-        // 获取审核人列表数据
-        this.getUserList()
-        // 获取盘点仓库
-        this._getWarehouse()
-        // 获取计划单号
-        this.getOrderCode()
-        // 获取规则名称
-        this._getRuleNameList()
+      id: {
+        type: String,
+        default: ''
       }
     },
-    planRulesDetails (val) {
-      if (!this.dialogVisible) return
-      this.addForm = val
-      this.addForm.assetsName = val.assetDictDESC
-      this.assetsType = val.assetDict
-      // this.warehousingType.map(item => {
-      //   if (val.assetsName == item.label) {
-      //     this.assetsType = item.code
-      //   }
-      // })
-      // this.assetsType = this.warehousingType.filter(
-      //   item => item.code === val.assetDict.code
-      // )[0].type
-      // this.addForm.assetDict = this.warehousingType.filter(
-      //   item => item.code === val.assetDict.code
-      // )[0].key
-      // 根据部门回显人员
-      const params = { deptCode: val.executorDeptCode, status: 1 }
-      this.getUserList(params)
-      this.planRuleInventoryDetailList = val.planRuleInventoryDetailList
-      console.log(
-        'planRuleInventoryDetailList',
-        this.planRuleInventoryDetailList
-      )
-      // 将 planRuleInventoryDetailList 保存到store,在 assets.vue 中获取用来高亮树节点和请求右边的列表
-      // 取出 planRuleInventoryDetailList 里面的分类 bizTypeId、bizTypeName,用来高亮树节点和请求右边的列表
-      // console.log('资产分类:', val.assetDict)
-      // console.log(this.addForm.assetsName)
-    }
-  },
-  computed: {
-    // ...mapGetters([
-    //   'equipmentList',
-    //   // 'ruleNameList',
-    //   'planRulesDetails',
-    //   'addDialogLoading',
-    //   'addOrUpdate'
-    // ])
-  },
-  methods: {
-    // 获取规则名列表
-    async _getRuleNameList () {
-      const res = await getRule({status:1,type:4,pageNum:1,size:-1})
-      if (res.list) {
-        this.ruleNameList = res.list || []
-      }
+    components: {
+      deptSelect,
+      AssetsInWarehouse,
+      selectTree
     },
-	// 获取计划配置单号
-	async getOrderCode (tips) {
-		const code = await getCode('inventoryconfig_code');
-		this.$set(this.addForm, 'code', code);
-	}, 
-    // 关闭弹窗
-    handleClose () {
-      this.dialogVisible = false
-      this.$refs.addFormRef.resetFields()
-      if (this.$refs.searchTree) {
-        this.$refs.searchTree.clearHandle()
-      }
-      if (this.addForm.bizType == 2) {
-        this.$refs.assetsRef._clearTreeTableData()
-      }
-      this.addForm.assetsName = ''
-      this.assetsType = null
-      this.addForm = {
-        code: '', // 计划配置单号
-        planRuleName: '', // 计划配置名称
-        isSyncBill: null, // 是否自动派单
-        ruleId: '', // 规则名称
-        bizType: '', // 盘点类型
-        bizTypeId: '', // 盘点仓库Id
-        bizTypeName: '', // 盘点仓库name
-        verifyUserId: '', // 审核人Id
-        verifyUserName: '', // 审核人name
-        duration: null, // 盘点时长
-        assetDict: '', // 资产分类id
-        assetsName: '', // 资产分类name
-        urgent: null, // 紧急程度
-        executorDeptCode: '', // 执行部门code
-        executorDeptName: '', // 执行部门name
-        executorId: '', // 执行人id
-        executorName: '', // 执行人name
-        isTreasuryLock: false, // 是否锁库盘点
-        status: true, // 状态
-        remark: '' // 备注
-      }
-    },
-
-    // 封装 - 获取盘点仓库
-    async _getWarehouse () {
-	  const params =  {  pageNum: 1 ,size:-1 }
-      const res = await getWarehouseList(params)
-	  this.warehouseList = res.list
+    data() {
+      return {
+        factoryOptions: [],
+        workshopOptions: [],
+        productionLineOptions: [],
+        stationOptions: [],
+        codeList: [],
+        inventoryTypeStatus,
+        addDialogLoading: false,
+        dialogVisible: false,
+        wh_checkStatus: [], // 盘点类型
+        warehouseList: [], // 盘点仓库
+        uerList: [], // 审核人
+        executorList: [], // 执行人
+        assetsType: null,
+        planRuleInventoryDetailList: [],
+        addForm: {
+          code: '', // 计划配置单号
+          planName: '', // 计划配置名称
+          categoryId: 0, // 类别ID
+          autoOrder: 1, // 是否自动派单
+          ruleId: '', // 规则名称
+          inventoryType: '', // 盘点类型
+          bizTypeId: '', // 盘点仓库Id
+          bizTypeName: '', // 盘点仓库name
+          verifyUserId: '', // 审核人Id
+          verifyUserName: '', // 审核人name
+          duration: null, // 盘点时长
+          assetDict: '', // 资产分类id
+          assetsName: '', // 资产分类name
+          urgent: '1', // 紧急程度
+          executeGroupId: '', // 执行部门code
+          executeGroupName: '', // 执行部门name
+          executorId: '', // 执行人id
+          executorName: '', // 执行人name
+          isTreasuryLock: false, // 是否锁库盘点
+          enable: 1, // 状态
+          remark: '', // 备注
+          productionLineId: '',
+          productionLineName: '',
+          workshopId: '',
+          workshopName: '',
+          plantId: '',
+          plantName: '',
+          stationId: '',
+          stationName: ''
+        },
+        rules: {
+          planName: [
+            { required: true, message: '请输入计划配置名称', trigger: 'blur' }
+          ],
+          autoOrder: [
+            { required: true, message: '请选择是否自动派单', trigger: 'change' }
+          ],
+          ruleId: [
+            { required: true, message: '请选择规则名称', trigger: 'change' }
+          ],
+          duration: [
+            { required: true, message: '请输入计划完成时长', trigger: 'blur' }
+          ],
+          inventoryType: [
+            { required: true, message: '请选择盘点类型', trigger: 'change' }
+          ],
+          // plantId: [
+          //   {
+          //     required: true,
+          //     message: '请选择厂房',
+          //     trigger: 'change'
+          //   }
+          // ],
+          warehouseId: [
+            { required: true, message: '请选择盘点仓库', trigger: 'change' }
+          ],
+          verifyUserId: [
+            { required: false, message: '请选择审核人', trigger: 'change' }
+          ],
+          executeGroupId: [
+            { required: true, message: '请选择选择执行部门', trigger: 'change' }
+          ],
+          executorId: [
+            { required: true, message: '请选择选择执行人员', trigger: 'change' }
+          ],
+          assetDict: [
+            { required: true, message: '请选择资产分类', trigger: 'change' }
+          ]
+        },
+        ruleNameList: []
+      };
     },
-
-    //选择部门(搜索)
-    searchDeptNodeClick (info) {
-      if (info) {
-		   const params = { groupId: info }
-		   this.getUserList(params)
-      } else {
-        this.addForm.executorDeptCode = null
+    watch: {
+      dialogVisible(val) {
+        if (val) {
+          // // 获取审核人列表数据
+          // this.getUserList();
+          // 获取盘点仓库
+          this._getWarehouse();
+          // 获取计划单号
+          this.getOrderCode();
+          // 获取规则名称
+          this._getRuleNameList();
+          // 获取物品类型
+          this.getGoodsList();
+          // 获取工厂列表
+          this.getFactoryareaList();
+          if (
+            this.dialogTile === '修改盘点计划配置' ||
+            this.dialogTile === '盘点计划配置详情'
+          ) {
+            getInventoryDetailById(this.id).then((res) => {
+              console.log(res);
+              res.warehouseId = res.warehouseId > 0 ? res.warehouseId : '';
+              res.urgent = String(res.urgent);
+              this.addForm = res;
+              let locationIds = res.locationId && res.locationId.split(',');
+              let locationNames =
+                res.locationName && res.locationName.split(',');
+              this.addForm.plantId = locationIds[0];
+              this.addForm.workshopId = locationIds[1];
+              this.addForm.productionLineId = locationIds[2];
+              this.addForm.stationId = locationIds[3];
+              this.addForm.plantName = locationNames[0];
+              this.addForm.workshopName = locationNames[1];
+              this.addForm.productionLineName = locationNames[2];
+              this.addForm.stationName = locationNames[3];
+              if (this.addForm.inventoryType === 2) {
+                if (this.addForm.plantId) {
+                  this.getListWorkshopByParentId(this.addForm.plantId);
+                }
+                if (this.addForm.workshopId) {
+                  this.getlistFactoryLineByParentId(this.addForm.workshopId);
+                }
+                if (this.addForm.productionLineId) {
+                  this.getlistByProductionLineId(this.addForm.productionLineId);
+                }
+              } else {
+                this.addForm.plantId = '';
+                this.addForm.workshopId = '';
+                this.addForm.productionLineId = '';
+                this.addForm.stationId = '';
+                this.workshopOptions = [];
+                this.productionLineOptions = [];
+                this.stationOptions = [];
+              }
+              if (this.addForm.executeGroupId) {
+                this.getUserList({ groupId: this.addForm.executeGroupId });
+              }
+            });
+          } else {
+            this.addForm.plantId = '';
+            this.addForm.workshopId = '';
+            this.addForm.productionLineId = '';
+            this.addForm.stationId = '';
+            this.workshopOptions = [];
+            this.productionLineOptions = [];
+            this.stationOptions = [];
+            this.executorList = [];
+          }
+        }
+      },
+      planRulesDetails(val) {
+        if (!this.dialogVisible) return;
+        this.addForm = val;
+        this.addForm.assetsName = val.assetDictDESC;
+        this.assetsType = val.assetDict;
+        // this.warehousingType.map(item => {
+        //   if (val.assetsName == item.label) {
+        //     this.assetsType = item.code
+        //   }
+        // })
+        // this.assetsType = this.warehousingType.filter(
+        //   item => item.code === val.assetDict.code
+        // )[0].type
+        // this.addForm.assetDict = this.warehousingType.filter(
+        //   item => item.code === val.assetDict.code
+        // )[0].key
+        // 根据部门回显人员
+        const params = { deptCode: val.executeGroupId, status: 1 };
+        this.getUserList(params);
+        this.planRuleInventoryDetailList = val.planRuleInventoryDetailList;
+        console.log(
+          'planRuleInventoryDetailList',
+          this.planRuleInventoryDetailList
+        );
+        // 将 planRuleInventoryDetailList 保存到store,在 assets.vue 中获取用来高亮树节点和请求右边的列表
+        // 取出 planRuleInventoryDetailList 里面的分类 bizTypeId、bizTypeName,用来高亮树节点和请求右边的列表
+        // console.log('资产分类:', val.assetDict)
+        // console.log(this.addForm.assetsName)
       }
     },
-	
-	// 获取审核人列表、巡点检人员
-	async getUserList (params) {
-	  try {
-	    let data = {  pageNum: 1 ,size:-1 }
-	    // 如果传了参数就是获取巡点检人员数据
-	    if (params) {
-	      data = Object.assign(data, params)
-	    }
-	    const res = await getUserPage(data)
-	    if (params) {
-	      this.executorList = res.list
-	    } else {
-	      this.uerList = res.list
-	    }
-	  } catch (error) {}
-	},
-
-    // 资产分类
-    handleAssetsChange (item) {
-      this.addForm.assetsName = item.dictValue
-      this.assetsType = item.dictCode
-      this.$nextTick(
-        () => this.$refs.assetsRef && this.$refs.assetsRef.handleAssetsChange()
-      )
+    computed: {
+      // ...mapGetters([
+      //   'equipmentList',
+      //   // 'ruleNameList',
+      //   'planRulesDetails',
+      //   'addDialogLoading',
+      //   'addOrUpdate'
+      // ])
     },
+    methods: {
+      // 改变规则名称
+      change_ruleId(val) {
+        this.addForm.ruleName = this.ruleNameList.filter(
+          (item) => item.id === val
+        )[0].name;
+      },
+      // 获取工厂数据
+      getFactoryareaList() {
+        getFactoryarea({
+          type: 1,
+          size: 9999,
+          type: 2
+        }).then((res) => {
+          this.factoryOptions = res.list;
+        });
+      },
+      change_factoryId(id) {
+        this.addForm.workshopId = '';
+        this.addForm.productionLineId = '';
+        this.addForm.stationId = '';
+        this.workshopOptions = [];
+        this.productionLineOptions = [];
+        this.stationOptions = [];
+        this.addForm.plantId = id;
+        this.addForm.plantName = this.factoryOptions.filter(
+          (item) => item.id === id
+        )[0].pathName;
+        this.getListWorkshopByParentId(id);
+      },
+      // 获取车间
+      getListWorkshopByParentId(id) {
+        listWorkshopByParentId(id).then((res) => {
+          this.workshopOptions = res;
+        });
+      },
+      change_workshop(id) {
+        this.addForm.productionLineId = '';
+        this.addForm.stationId = '';
+        this.productionLineOptions = [];
+        this.stationOptions = [];
+        this.addForm.workshopName = this.workshopOptions.filter(
+          (item) => item.id === id
+        )[0].name;
+        this.getlistFactoryLineByParentId(id);
+      },
+      // 获取产线
+      getlistFactoryLineByParentId(id) {
+        listFactoryLine([id]).then((res) => {
+          this.productionLineOptions = res;
+        });
+      },
+      change_productionLineId(id) {
+        this.addForm.stationId = '';
+        this.stationOptions = [];
+        this.addForm.productionLineName = this.productionLineOptions.filter(
+          (item) => item.id === id
+        )[0].name;
+        this.getlistByProductionLineId(id);
+      },
+      // 获取工位
+      getlistByProductionLineId(id) {
+        listByProductionLineId(id).then((res) => {
+          this.stationOptions = res;
+        });
+      },
+      change_stationId(id) {
+        this.$forceUpdate();
+        this.addForm.stationName = this.stationOptions.filter(
+          (item) => item.id === id
+        )[0].name;
+      },
+      // 物品类型选择
+      codeListValue(val) {
+        console.log('val---------', val);
+        this.addForm.categoryLevelId = val?.id;
+        this.addForm.categoryLevelName = val?.name;
+      },
+      // 获取物品类型列表
+      async getGoodsList() {
+        const { data } = await getTreeByGroup({ type: 2 });
+        this.codeList = data;
+      },
+      // 获取规则名列表
+      async _getRuleNameList() {
+        const res = await getRule({ status: 1, type: 4, pageNum: 1, size: -1 });
+        if (res.list) {
+          this.ruleNameList = res.list || [];
+        }
+      },
+      // 获取计划配置单号
+      async getOrderCode(tips) {
+        const code = await getCode('inventoryconfig_code');
+        this.$set(this.addForm, 'planCode', code);
+      },
+      // 执行人选择
+      changeExecutor(val) {
+        if (val) {
+          this.addForm.executorId = val;
+          this.addForm.executorName = this.executorList.filter(
+            (item) => item.id === val
+          )[0].name;
+        }
+      },
+      // 仓库选择
+      changeWarehouse(val) {
+        if (val) {
+          this.addForm.warehouseId = val;
+          this.addForm.warehouseName = this.warehouseList.filter(
+            (item) => item.id === val
+          )[0].name;
+        }
+      },
+      // 关闭弹窗
+      handleClose() {
+        this.dialogVisible = false;
+        this.$refs.addFormRef.resetFields();
+        if (this.$refs.searchTree) {
+          this.$refs.searchTree.clearHandle();
+        }
+        if (this.addForm.inventoryType == 2) {
+          this.$refs.assetsRef._clearTreeTableData();
+        }
+        this.addForm.assetsName = '';
+        this.assetsType = null;
+        this.addForm = {
+          code: '', // 计划配置单号
+          planName: '', // 计划配置名称
+          categoryId: 0,
+          autoOrder: 1, // 是否自动派单
+          ruleId: '', // 规则名称
+          inventoryType: '', // 盘点类型
+          bizTypeId: '', // 盘点仓库Id
+          bizTypeName: '', // 盘点仓库name
+          verifyUserId: '', // 审核人Id
+          verifyUserName: '', // 审核人name
+          duration: null, // 盘点时长
+          assetDict: '', // 资产分类id
+          assetsName: '', // 资产分类name
+          urgent: '1', // 紧急程度
+          executeGroupId: '', // 执行部门code
+          executeGroupName: '', // 执行部门name
+          executorId: '', // 执行人id
+          executorName: '', // 执行人name
+          isTreasuryLock: false, // 是否锁库盘点
+          enable: 1, // 状态
+          remark: '' // 备注
+        };
+      },
 
-    // 参数处理
-    getParams () {
-      const { classificationList, tableSelectionList } =
-      this.$refs.assetsRef.getSelectList()
-      console.log('getParams-tableSelectionList',tableSelectionList)
-      return {
-        ...this.addForm,
-        classificationList: classificationList.map(i => ({
-          classificationID: i.id,
-          classificationName: i.name
-        })),
-        planRuleInventoryDetailList:
-          this.formData && this.formData.bizType === 2
-            ? tableSelectionList.map(item => ({
-                assetBrand: item.brand,
-                assetCode: item.code,
-                assetId: item.id,
-                assetLocationId: `${this.initLocation(
-                  item.positionWorkshop
-                )}${this.initLocation(item.positionLine)}${this.initLocation(
-                  item.positionFarm
-                )}${this.initLocation(item.positionFactory)}`,
-                assetLocationName: `${this.initLocation(
-                  item.positionWorkshopCode
-                )}${this.initLocation(
-                  item.positionLineCode
-                )}${this.initLocation(
-                  item.positionFarmCode
-                )}${this.initLocation(item.positionFactoryCode)}`,
-                assetName: item.name,
-                assetSku: item.specifications,
-                assetTypeDict: this.addForm ? this.addForm.assetDict : '',
-                bizTypeId: item.bizTypeId,
-                bizTypeName: item.bizTypeName,
-                unit: this.addForm ? this.addForm.unit : ''
-              }))
-            : tableSelectionList,
-        planRuleType: 'INVENTORY'
-      }
-
-    },
-    initLocation (inp) {
-      return inp ? inp + ',' : ''
-    },
+      // 封装 - 获取盘点仓库
+      async _getWarehouse() {
+        const res = await getWarehouseList({});
+        console.log(res);
+        this.warehouseList = res.map((item) => {
+          return { ...item, name: item.factoryName + '-' + item.name };
+        });
+      },
 
-    // x选择盘点类型
-    chooseType (val) {
-      if (val == 2) {
-        this.addForm.bizTypeId = null
-        this.addForm.bizTypeName = null
-      }
-    },
+      //选择部门(搜索)
+      searchDeptNodeClick(info, row) {
+        if (info) {
+          const params = { groupId: info };
+          this.getUserList(params);
+          this.addForm.executeGroupName = row.name;
+        } else {
+          this.addForm.executeGroupId = null;
+        }
+      },
 
-    // 提交
-    submit () {
-      this.$refs.addFormRef.validate(async valid => {
-        if (valid) {
-          const params = this.getParams()
-          console.log('planRuleInventoryDetailList',params.planRuleInventoryDetailList)
-          if(this.addOrUpdate!='edit'){
-              if (
-                !(
-                  params.classificationList.length ||
-                  params.planRuleInventoryDetailList.length
-                )
-              ) {
-                return this.$message.error('请选择资产分类台账!')
-              }
+      // 获取审核人列表、巡点检人员
+      async getUserList(params) {
+        try {
+          let data = { pageNum: 1, size: -1 };
+          // 如果传了参数就是获取巡点检人员数据
+          if (params) {
+            data = Object.assign(data, params);
           }
-          const res = await planRules.handleSaveOrUpdate(params)
-          if (res?.success) {
-            this.handleClose()
-            this.$message.success('保存成功!')
-            this.$emit('refreshList')
+          const res = await getUserPage(data);
+          if (params) {
+            this.executorList = res.list;
+          } else {
+            this.uerList = res.list;
           }
+        } catch (error) {}
+      },
+
+      // 资产分类
+      handleAssetsChange(item) {
+        this.addForm.assetsName = item.dictValue;
+        this.assetsType = item.dictCode;
+        this.$nextTick(
+          () =>
+            this.$refs.assetsRef && this.$refs.assetsRef.handleAssetsChange()
+        );
+      },
+
+      // 参数处理
+      getParams() {
+        const { classificationList, tableSelectionList } =
+          this.$refs.assetsRef.getSelectList();
+        console.log('getParams-tableSelectionList', tableSelectionList);
+        return {
+          ...this.addForm,
+          classificationList: classificationList.map((i) => ({
+            classificationID: i.id,
+            classificationName: i.name
+          })),
+          planRuleInventoryDetailList:
+            this.formData && this.formData.inventoryType === 2
+              ? tableSelectionList.map((item) => ({
+                  assetBrand: item.brand,
+                  assetCode: item.code,
+                  assetId: item.id,
+                  assetLocationId: `${this.initLocation(
+                    item.positionWorkshop
+                  )}${this.initLocation(item.positionLine)}${this.initLocation(
+                    item.positionFarm
+                  )}${this.initLocation(item.positionFactory)}`,
+                  assetLocationName: `${this.initLocation(
+                    item.positionWorkshopCode
+                  )}${this.initLocation(
+                    item.positionLineCode
+                  )}${this.initLocation(
+                    item.positionFarmCode
+                  )}${this.initLocation(item.positionFactoryCode)}`,
+                  assetName: item.name,
+                  assetSku: item.specifications,
+                  assetTypeDict: this.addForm ? this.addForm.assetDict : '',
+                  bizTypeId: item.bizTypeId,
+                  bizTypeName: item.bizTypeName,
+                  unit: this.addForm ? this.addForm.unit : ''
+                }))
+              : tableSelectionList,
+          planRuleType: 'INVENTORY'
+        };
+      },
+      initLocation(inp) {
+        return inp ? inp + ',' : '';
+      },
+
+      // x选择盘点类型
+      chooseType(val) {
+        if (val == 2) {
+          this.addForm.warehouseId = '';
+          this.addForm.warehouseName = '';
+          this.addForm.lockWarehouse = 0;
+        } else {
+          this.addForm.plantId = '';
+          this.addForm.workshopId = '';
+          this.addForm.productionLineId = '';
+          this.addForm.stationId = '';
+          this.workshopOptions = [];
+          this.productionLineOptions = [];
+          this.stationOptions = [];
         }
-      })
-    },
-    handleChangeassetDict(data){
-        console.log(data)
+      },
+
+      // 提交
+      submit() {
+        console.log(this.addForm);
+        this.$refs.addFormRef.validate(async (valid) => {
+          if (valid) {
+            // const params = this.getParams();
+            // console.log(
+            //   'planRuleInventoryDetailList',
+            //   params.planRuleInventoryDetailList
+            // );
+            // if (this.addOrUpdate != 'edit') {
+            //   if (
+            //     !(
+            //       params.classificationList.length ||
+            //       params.planRuleInventoryDetailList.length
+            //     )
+            //   ) {
+            //     return this.$message.error('请选择资产分类台账!');
+            //   }
+            // }
+            if (this.addForm.inventoryType == 2) {
+              this.addForm.locationId = [
+                this.addForm.plantId,
+                this.addForm.workshopId,
+                this.addForm.productionLineId,
+                this.addForm.stationId
+              ].join(',');
+              this.addForm.locationName = [
+                this.addForm.plantName,
+                this.addForm.workshopName,
+                this.addForm.productionLineName,
+                this.addForm.stationName
+              ].join(',');
+            }
+            if (!this.addForm.warehouseId) {
+              this.addForm.warehouseId = 0;
+            }
+            if (this.addForm.inventoryType == 2 && !this.addForm.plantId) {
+              this.$message.error('请至少选择所属厂房!');
+              return false;
+            }
+            let res = '';
+            let message = '';
+            if (this.dialogTile === '修改盘点计划配置') {
+              res = await updateStocktakingPlan(this.addForm);
+              message = '修改成功!';
+            } else {
+              res = await saveStocktakingPlan(this.addForm);
+              message = '新增成功!';
+            }
+            if (res.code == 0) {
+              this.handleClose();
+              this.$message.success(message);
+              this.$emit('refreshList');
+            }
+          }
+        });
+      },
+      handleChangeassetDict(data) {
+        console.log(data);
+      }
     }
-  }
-}
+  };
 </script>
 
 <style lang="scss" scoped>
-.add_form {
-  ::v-deep .el-form-item {
-    margin-bottom: 20px !important;
+  ::v-deep .el-row {
+    display: flex;
+    flex-wrap: wrap;
+  }
+  .add_form {
+    ::v-deep .el-form-item {
+      margin-bottom: 20px !important;
+    }
   }
-}
 </style>

+ 133 - 52
src/views/rulesManagement/planRules/components/inventory-search.vue

@@ -9,80 +9,124 @@
     <el-row :gutter="15">
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="计划配置单号:">
-          <el-input clearable v-model="where.code" placeholder="请输入" />
+          <el-input clearable v-model="where.planCode" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="分类:">
+          <selectTree
+            ref="tree"
+            class="form-ipt"
+            size="medium"
+            style="width: 100%"
+            clearable
+            :options="codeList"
+            :props="{
+              value: 'id',
+              label: 'name',
+              children: 'children'
+            }"
+            @getValue="codeListValue"
+            :isAll="false"
+          />
+          <!-- <DictSelection dictName="类型用途" clearable v-model="where.staus">
+			</DictSelection> -->
         </el-form-item>
-		<el-form-item label="资产分类:">
-			<DictSelection dictName="类型用途" clearable v-model="where.staus">
-			</DictSelection>
-		</el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="盘点名称:">
-          <el-input clearable v-model="where.name" placeholder="请输入" />
+          <el-input clearable v-model="where.planName" placeholder="请输入" />
         </el-form-item>
         <el-form-item label="规则名称:">
-           <el-input clearable v-model="where.name" placeholder="请输入" />
+          <el-select
+            v-model="where.ruleId"
+            class="w100"
+            placeholder="请选择规则名称"
+            :disabled="isBindPlan"
+            filterable
+          >
+            <el-option
+              v-for="item in ruleNameList"
+              :key="item.id"
+              :value="item.id"
+              :label="item.name"
+            ></el-option>
+          </el-select>
+          <!-- <el-input clearable v-model="where.ruleName" placeholder="请输入" /> -->
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="盘点部门:">
-          <deptSelect v-model="where.groupId" />
+          <deptSelect
+            v-model="where.executeGroupId"
+            @changeGroup="changeExecuteGroupId"
+          />
         </el-form-item>
-		<el-form-item label="创建时间:">
-			<el-date-picker
-				v-model="where.time"
-				type="daterange"
-				range-separator="至"
-				start-placeholder="开始日期"
-				end-placeholder="结束日期"
-				value-format="yyyy-MM-dd HH:mm:ss"
-				:default-time="['00:00:00', '23:59:59']"
-			  >
-			</el-date-picker>
-		</el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="盘点名称:">
-          <el-input clearable v-model="where.texture" placeholder="请输入" />
+        <el-form-item label="开始结束时间:">
+          <el-date-picker
+            style="width: 100%"
+            v-model="dateTime"
+            type="daterange"
+            range-separator="至"
+            start-placeholder="开始日期"
+            end-placeholder="结束日期"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            :default-time="['00:00:00', '23:59:59']"
+            @change="timeChange"
+          >
+          </el-date-picker>
         </el-form-item>
-		<div class="ele-form-actions">
-			<el-button
-				type="primary"
-				icon="el-icon-search"
-				class="ele-btn-icon"
-				@click="search"
-				size="small"
-			>
-				查询
-			</el-button>
-			 <el-button @click="reset"
-				 icon="el-icon-refresh-left"
-				 size="small"
-				 type="primary"
-			 >重置</el-button>
-		</div>
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+            size="small"
+          >
+            查询
+          </el-button>
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh-left"
+            size="small"
+            type="primary"
+            >重置</el-button
+          >
+        </div>
       </el-col>
     </el-row>
   </el-form>
 </template>
 
 <script>
+  import { getRule } from '@/api/ruleManagement/plan';
+  import { getTreeByGroup } from '@/api/classifyManage';
   import { login } from '@/api/login';
-	import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  import selectTree from '@/components/selectTree';
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
   export default {
-		components: { deptSelect },
+    components: { deptSelect, selectTree },
     data() {
       // 默认表单数据
       const defaultWhere = {
-        name: '',
-        code: '',
-        fixCode:'',
-        ownershipGroupId:''
+        planCode: '',
+        planName: '',
+        ruleId: '',
+        categoryLevelId: '',
+        createTimeStart: '',
+        createTimeEnd: '',
+        executeGroupId: ''
       };
       return {
+        codeList: [],
+        ruleNameList: [],
+        isBindPlan: false,
+        dateTime: '',
+        codeList: [],
         // 表单数据
         where: { ...defaultWhere },
-        treeData:[]
+        treeData: []
       };
     },
     computed: {
@@ -91,9 +135,45 @@
         return this.$store.state.theme.styleResponsive;
       }
     },
-    created(){
+    created() {
+      this.getGoodsList();
+      this._getRuleNameList();
     },
     methods: {
+      timeChange(val) {
+        if (val) {
+          this.where.createTimeStart = val[0];
+          this.where.createTimeEnd = val[1];
+        } else {
+          this.where.createTimeStart = '';
+          this.where.createTimeEnd = '';
+        }
+      },
+      changeExecuteGroupId(val) {
+        if (!val) {
+          this.where.executeGroupId = '';
+        }
+      },
+      // 获取规则名列表
+      async _getRuleNameList() {
+        const res = await getRule({ status: 1, type: 4, pageNum: 1, size: -1 });
+        if (res.list) {
+          this.ruleNameList = res.list || [];
+        }
+      },
+      // 物品类型选择
+      codeListValue(val) {
+        if (val) {
+          this.where.categoryLevelId = val?.id;
+        } else {
+          this.where.categoryLevelId = '';
+        }
+      },
+      // 获取物品类型列表
+      async getGoodsList() {
+        const { data } = await getTreeByGroup({ type: 2 });
+        this.codeList = data;
+      },
       /* 搜索 */
       search() {
         console.log(this.where);
@@ -101,6 +181,7 @@
       },
       /*  重置 */
       reset() {
+        this.dateTime = '';
         this.where = { ...this.defaultWhere };
         this.search();
       }
@@ -108,9 +189,9 @@
   };
 </script>
 <style lang="scss" scoped>
-    .ele-form-actions{
-		display:flex;
-		align-items: center;
-		justify-content: flex-end;
-	}
-</style>
+  .ele-form-actions {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+  }
+</style>

+ 339 - 335
src/views/rulesManagement/planRules/detail.vue

@@ -14,7 +14,7 @@
         <span>{{ infoData.createTime }}</span>
       </div>
     </div>
-<!--    <div class="switch mt40">
+    <!--    <div class="switch mt40">
       <div class="switch_left">
         <ul>
           <li :class="{ active: num == 1 }" @click="selectActive(1)">详情</li>
@@ -24,7 +24,7 @@
 
     <div v-if="num === 1">
       <div class="content-detail mt40">
-		<HeaderTitle title="派单信息" size="16px"></HeaderTitle>
+        <HeaderTitle title="派单信息" size="16px"></HeaderTitle>
         <div class="mt20">
           <el-form label-width="130px">
             <el-col :span="8">
@@ -74,7 +74,7 @@
             </el-col>
             <el-col :span="8">
               <el-form-item label="紧急程度">
-                {{ infoData.urgent | useDictLabelFilter(emergencyState) }}
+                {{ infoData.urgent }}
               </el-form-item>
             </el-col>
             <el-col :span="8">
@@ -100,7 +100,7 @@
         </div>
       </div>
       <div class="content-detail mt20">
-		<HeaderTitle title="盘点明细" size="16px"></HeaderTitle>
+        <HeaderTitle title="盘点明细" size="16px"></HeaderTitle>
         <div class="mt20">
           <el-form label-width="80px" label-position="top">
             <el-form-item>
@@ -133,7 +133,10 @@
                   label="牌号"
                   prop="assetBrand"
                 ></el-table-column>
-                <el-table-column label="型号" prop="equiModel"></el-table-column>
+                <el-table-column
+                  label="型号"
+                  prop="equiModel"
+                ></el-table-column>
                 <el-table-column label="类型" prop="assetTypeDict.descp">
                   <template>
                     {{ infoData.assetDict && infoData.assetDict.descp }}
@@ -158,371 +161,372 @@
 </template>
 
 <script>
-// import { getPlanDetail, workOrderDetails } from '@/api/stockManagement/stocking'
-// import PageHeader from '@/components/PageHeader'
-// import StatusStep from '@/components/StatusStep'
-// import { useDictLabelFilter } from '@/utils/dict'
+  import { getInventoryDetailById } from '@/api/ruleManagement/plan';
+  // import { getPlanDetail, workOrderDetails } from '@/api/stockManagement/stocking'
+  // import PageHeader from '@/components/PageHeader'
+  // import StatusStep from '@/components/StatusStep'
+  // import { useDictLabelFilter } from '@/utils/dict'
 
-// import {
-//   wh_planStatus,
-//   wh_checkStatus,
-//   emergencyState,
-//   warehousingType
-// } from '@/utils/dict/warehouse'
-export default {
-  // components: { PageHeader, StatusStep },
-  // filters: {
-  //   useDictLabelFilter: useDictLabelFilter
-  // },
-  data () {
-    return {
-      emergencyState,
-      wh_checkStatus,
-      wh_planStatus,
-      activeName: 'a',
-      num: 1,
-      workOrderData: [],
-      infoData: {},
-      stepsList: [
-        { status: 'Done', nodeName: '创建' },
-        { status: 'Done', nodeName: '审批中' },
-        { status: 'Done', nodeName: '审批完成' },
-        { status: 'Processing', nodeName: '已收货' },
-        { status: '', nodeName: '收货中' },
-        { status: '', nodeName: '已收货' }
-      ],
-      btnList1: [
-        { name: '受理' },
-        {
-          name: '作废'
-        },
-        {
-          name: '执行'
-        },
-        {
-          name: '编辑'
-        },
-        {
-          name: '确认'
-        },
-        {
-          name: '打印'
-        },
-        {
-          name: '关闭'
-        }
-      ],
-      btnList2: [
-        {
-          name: '撤销'
-        },
-        {
-          name: '催办'
-        },
-        {
-          name: '批复'
-        },
-        {
-          name: '编辑'
-        },
-        {
-          name: '提交'
-        },
-        {
-          name: '打印'
-        },
-        {
-          name: '关闭'
-        }
-      ],
-      list: [
-        {
-          name: '紧急',
-          color: 'red'
-        },
-        {
-          name: '重要',
-          color: 'blue'
-        },
-        {
-          name: '已催办',
-          color: 'red'
-        }
-      ],
-      detailsData: [],
-      tableData: [],
-      tableData1: [],
-      tableData2: []
-    }
-  },
-  created () {
-    this.getInfo()
-  },
-  methods: {
-    async getInfo () {
-      const res = await getPlanDetail({ id: this.$route.query.id })
-      if (res?.success) {
-        console.log(res)
-        this.infoData = res.data
-      }
-    },
-    selectActive (num) {
-      this.num = num
+  // import {
+  //   wh_planStatus,
+  //   wh_checkStatus,
+  //   emergencyState,
+  //   warehousingType
+  // } from '@/utils/dict/warehouse'
+  export default {
+    // components: { PageHeader, StatusStep },
+    // filters: {
+    //   useDictLabelFilter: useDictLabelFilter
+    // },
+    data() {
+      return {
+        emergencyState,
+        wh_checkStatus,
+        wh_planStatus,
+        activeName: 'a',
+        num: 1,
+        workOrderData: [],
+        infoData: {},
+        stepsList: [
+          { status: 'Done', nodeName: '创建' },
+          { status: 'Done', nodeName: '审批中' },
+          { status: 'Done', nodeName: '审批完成' },
+          { status: 'Processing', nodeName: '已收货' },
+          { status: '', nodeName: '收货中' },
+          { status: '', nodeName: '已收货' }
+        ],
+        btnList1: [
+          { name: '受理' },
+          {
+            name: '作废'
+          },
+          {
+            name: '执行'
+          },
+          {
+            name: '编辑'
+          },
+          {
+            name: '确认'
+          },
+          {
+            name: '打印'
+          },
+          {
+            name: '关闭'
+          }
+        ],
+        btnList2: [
+          {
+            name: '撤销'
+          },
+          {
+            name: '催办'
+          },
+          {
+            name: '批复'
+          },
+          {
+            name: '编辑'
+          },
+          {
+            name: '提交'
+          },
+          {
+            name: '打印'
+          },
+          {
+            name: '关闭'
+          }
+        ],
+        list: [
+          {
+            name: '紧急',
+            color: 'red'
+          },
+          {
+            name: '重要',
+            color: 'blue'
+          },
+          {
+            name: '已催办',
+            color: 'red'
+          }
+        ],
+        detailsData: [],
+        tableData: [],
+        tableData1: [],
+        tableData2: []
+      };
     },
-    async _workOrderDetails () {
-      const res = await workOrderDetails()
+    created() {
+      this.getInfo();
     },
-    // 时间差计算
-    difference (beginTime, endTime) {
-      var dateBegin = new Date(beginTime)
-      var dateEnd = new Date(endTime)
-      var dateDiff = dateEnd.getTime() - dateBegin.getTime() //时间差的毫秒数
-      var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)) //计算出相差天数
-      var leave1 = dateDiff % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
-      var hours = Math.floor(leave1 / (3600 * 1000)) //计算出小时数
-      //计算相差分钟数
-      var leave2 = leave1 % (3600 * 1000) //计算小时数后剩余的毫秒数
-      var minutes = Math.floor(leave2 / (60 * 1000)) //计算相差分钟数
-      //计算相差秒数
-      var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
-      var seconds = Math.round(leave3 / 1000)
+    methods: {
+      async getInfo() {
+        const res = await getInventoryDetailById(this.$route.query.id);
+        if (res?.success) {
+          console.log(res);
+          this.infoData = res.data;
+        }
+      },
+      selectActive(num) {
+        this.num = num;
+      },
+      async _workOrderDetails() {
+        const res = await workOrderDetails();
+      },
+      // 时间差计算
+      difference(beginTime, endTime) {
+        var dateBegin = new Date(beginTime);
+        var dateEnd = new Date(endTime);
+        var dateDiff = dateEnd.getTime() - dateBegin.getTime(); //时间差的毫秒数
+        var dayDiff = Math.floor(dateDiff / (24 * 3600 * 1000)); //计算出相差天数
+        var leave1 = dateDiff % (24 * 3600 * 1000); //计算天数后剩余的毫秒数
+        var hours = Math.floor(leave1 / (3600 * 1000)); //计算出小时数
+        //计算相差分钟数
+        var leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数
+        var minutes = Math.floor(leave2 / (60 * 1000)); //计算相差分钟数
+        //计算相差秒数
+        var leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数
+        var seconds = Math.round(leave3 / 1000);
 
-      if (dayDiff == -1) {
-        dayDiff = 0
-        hours = 0
-        minutes = 0
-      }
+        if (dayDiff == -1) {
+          dayDiff = 0;
+          hours = 0;
+          minutes = 0;
+        }
 
-      return dayDiff + '天' + hours + '小时' + minutes + '分钟'
+        return dayDiff + '天' + hours + '小时' + minutes + '分钟';
+      }
     }
-  }
-}
+  };
 </script>
 
 <style lang="scss" scoped>
-	.content-height{
-		background: #fff;
-	}
-.p20 {
-  padding: 20px;
-}
-.flex {
-  display: flex;
-}
-.title {
-  justify-content: space-between;
-  border-bottom: 1px solid #ccc;
-  padding-bottom: 5px;
-  span {
-    font-size: 16px;
-  }
-  .col {
-    padding-left: 40px;
-    font-size: 14px;
-    color: #aaaaaa;
+  .content-height {
+    background: #fff;
   }
-}
-.degree {
-  margin-right: 10px;
-  padding: 0px 15px;
-  color: #fff;
-  font-size: 13px;
-  line-height: 23px;
-  border-radius: 23px;
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  span {
-    width: 5px;
-    height: 5px;
-    border-radius: 100%;
-    margin-right: 6px;
-    background-color: #fff;
+  .p20 {
+    padding: 20px;
   }
-}
-.red {
-  background-color: rgb(163, 0, 20);
-}
-.blue {
-  background-color: #1989fa;
-}
-.createdInfo {
-  justify-content: space-around;
-  margin-top: 10px;
-  font-size: 14px;
-  .col {
-    color: #6e6e6e;
-    padding-right: 10px;
+  .flex {
+    display: flex;
   }
-}
-.mt40 {
-  margin-top: 40px;
-}
-
-.custSteps {
-  margin-top: 20px;
-  margin-left: 70px;
-
-  .box {
-    width: 158px;
-    border: 1px solid #ccc;
-    padding: 10px;
-    flex-direction: row;
-    flex-wrap: wrap;
-    // justify-content: space-between;
-    font-size: 12px;
-    color: #9e9e9e;
-    .x {
-      width: 20px;
-      height: 15px;
-      margin-right: 5px;
-    }
-    .q {
-      background-color: #d0e4d5;
+  .title {
+    justify-content: space-between;
+    border-bottom: 1px solid #ccc;
+    padding-bottom: 5px;
+    span {
+      font-size: 16px;
     }
-    .b {
-      background-color: #1989fa;
+    .col {
+      padding-left: 40px;
+      font-size: 14px;
+      color: #aaaaaa;
     }
-    .g {
-      background-color: #157a2c;
+  }
+  .degree {
+    margin-right: 10px;
+    padding: 0px 15px;
+    color: #fff;
+    font-size: 13px;
+    line-height: 23px;
+    border-radius: 23px;
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    span {
+      width: 5px;
+      height: 5px;
+      border-radius: 100%;
+      margin-right: 6px;
+      background-color: #fff;
     }
-    .r {
-      background-color: #a30014;
+  }
+  .red {
+    background-color: rgb(163, 0, 20);
+  }
+  .blue {
+    background-color: #1989fa;
+  }
+  .createdInfo {
+    justify-content: space-around;
+    margin-top: 10px;
+    font-size: 14px;
+    .col {
+      color: #6e6e6e;
+      padding-right: 10px;
     }
-    .a {
-      align-items: center;
-      margin-bottom: 10px;
+  }
+  .mt40 {
+    margin-top: 40px;
+  }
+
+  .custSteps {
+    margin-top: 20px;
+    margin-left: 70px;
+
+    .box {
+      width: 158px;
+      border: 1px solid #ccc;
+      padding: 10px;
+      flex-direction: row;
+      flex-wrap: wrap;
+      // justify-content: space-between;
+      font-size: 12px;
+      color: #9e9e9e;
+      .x {
+        width: 20px;
+        height: 15px;
+        margin-right: 5px;
+      }
+      .q {
+        background-color: #d0e4d5;
+      }
+      .b {
+        background-color: #1989fa;
+      }
+      .g {
+        background-color: #157a2c;
+      }
+      .r {
+        background-color: #a30014;
+      }
+      .a {
+        align-items: center;
+        margin-bottom: 10px;
+      }
+      .mr10 {
+        margin-right: 10px;
+      }
+      .mb0 {
+        margin-bottom: 0;
+      }
     }
-    .mr10 {
-      margin-right: 10px;
+    .stepsInfo {
+      // flex: 1;
+      width: 483px;
     }
-    .mb0 {
-      margin-bottom: 0;
+  }
+  .mt20 {
+    margin-top: 20px;
+  }
+  .content-detail {
+    overflow: hidden;
+  }
+  .executor {
+    font-size: 14px;
+    .col {
+      color: #6e6e6e;
+      padding-right: 10px;
     }
   }
-  .stepsInfo {
-    // flex: 1;
-    width: 483px;
+  .result {
+    justify-content: space-around;
   }
-}
-.mt20 {
-  margin-top: 20px;
-}
-.content-detail {
-  overflow: hidden;
-}
-.executor {
-  font-size: 14px;
-  .col {
-    color: #6e6e6e;
-    padding-right: 10px;
+  .mr20 {
+    margin-right: 20px;
+  }
+  .details {
+    font-size: 14px;
+    margin-bottom: 10px;
   }
-}
-.result {
-  justify-content: space-around;
-}
-.mr20 {
-  margin-right: 20px;
-}
-.details {
-  font-size: 14px;
-  margin-bottom: 10px;
-}
 
-.customSteps {
-  margin-top: 40px;
-  font-size: 14px;
-  margin-left: 80px;
-  .time {
-    font-size: 12px;
-    color: #6e6e6e;
-    margin-right: 20px;
-    position: relative;
-    .col {
-      color: #c1bdbd;
-      text-align: right;
+  .customSteps {
+    margin-top: 40px;
+    font-size: 14px;
+    margin-left: 80px;
+    .time {
+      font-size: 12px;
+      color: #6e6e6e;
+      margin-right: 20px;
+      position: relative;
+      .col {
+        color: #c1bdbd;
+        text-align: right;
+      }
+      &::after {
+        content: '';
+        width: 1px;
+        height: 100%;
+        background-color: #157a2c;
+        position: absolute;
+        right: -26px;
+      }
+    }
+    .flex:last-child {
+      .time {
+        &::after {
+          display: none;
+        }
+      }
     }
-    &::after {
-      content: '';
-      width: 1px;
-      height: 100%;
+    .round {
+      margin-right: 20px;
+      width: 10px;
+      height: 10px;
+      border-radius: 100%;
       background-color: #157a2c;
-      position: absolute;
-      right: -26px;
+      position: relative;
+      span {
+        position: absolute;
+        top: 50%;
+        left: 50%;
+        width: 4px;
+        height: 4px;
+        background-color: #fff;
+        border-radius: 100%;
+        transform: translate(-2px, -2px);
+      }
+    }
+    .text {
+      .info {
+        margin-top: 10px;
+        width: 955px;
+        background-color: #f0f3f3;
+        overflow: hidden;
+        padding: 10px;
+        margin-bottom: 10px;
+      }
     }
   }
-  .flex:last-child {
+  .customInfo {
     .time {
       &::after {
-        display: none;
+        top: 0;
+        right: -28px;
       }
     }
   }
-  .round {
-    margin-right: 20px;
-    width: 10px;
-    height: 10px;
-    border-radius: 100%;
-    background-color: #157a2c;
-    position: relative;
-    span {
-      position: absolute;
-      top: 50%;
-      left: 50%;
-      width: 4px;
-      height: 4px;
-      background-color: #fff;
-      border-radius: 100%;
-      transform: translate(-2px, -2px);
+  .tips {
+    font-size: 14px;
+    color: #6e6e6e;
+    margin-left: 52px;
+    .shape {
+      margin-left: 30px;
+      p {
+        margin-right: 10px;
+      }
     }
   }
-  .text {
-    .info {
-      margin-top: 10px;
-      width: 955px;
-      background-color: #f0f3f3;
-      overflow: hidden;
-      padding: 10px;
-      margin-bottom: 10px;
-    }
+  .f {
+    width: 15px;
+    height: 15px;
+    background-color: #157a2c;
+    border-radius: 3px;
   }
-}
-.customInfo {
-  .time {
-    &::after {
-      top: 0;
-      right: -28px;
-    }
+  .j {
+    width: 0;
+    height: 0;
+    border-left: 8px solid transparent;
+    border-right: 8px solid transparent;
+    border-bottom: 15px solid #157a2c;
   }
-}
-.tips {
-  font-size: 14px;
-  color: #6e6e6e;
-  margin-left: 52px;
-  .shape {
-    margin-left: 30px;
-    p {
-      margin-right: 10px;
-    }
+  .y {
+    width: 15px;
+    height: 15px;
+    border-radius: 100%;
+    background-color: #157a2c;
   }
-}
-.f {
-  width: 15px;
-  height: 15px;
-  background-color: #157a2c;
-  border-radius: 3px;
-}
-.j {
-  width: 0;
-  height: 0;
-  border-left: 8px solid transparent;
-  border-right: 8px solid transparent;
-  border-bottom: 15px solid #157a2c;
-}
-.y {
-  width: 15px;
-  height: 15px;
-  border-radius: 100%;
-  background-color: #157a2c;
-}
 </style>

+ 56 - 32
src/views/rulesManagement/planRules/index.vue

@@ -26,7 +26,8 @@
           <Maintenance />
         </div>
         <div v-if="activeComp == 'plan'" class="plan">
-          <inventory-search @search="reload"> </inventory-search>
+          <inventory-search ref="inventorySearch" @search="reload">
+          </inventory-search>
           <!-- 数据表格 -->
           <ele-pro-table
             ref="table"
@@ -35,7 +36,7 @@
             cache-key="systemRoleTable14"
           >
             <!-- 表头工具栏 -->
-            <template v-slot:toolbar>
+            <template v-slot:toolbar="{ row }">
               <el-button
                 size="small"
                 type="primary"
@@ -45,14 +46,6 @@
               >
                 新建
               </el-button>
-              <el-button
-                size="small"
-                type="primary"
-                class="ele-btn-icon"
-                @click="goDetail()"
-              >
-                详情
-              </el-button>
             </template>
             <!-- 操作列 -->
             <template v-slot:action="{ row }">
@@ -64,6 +57,13 @@
               >
                 修改
               </el-link>
+              <el-link
+                type="primary"
+                class="ele-btn-icon"
+                @click="goDetail(row)"
+              >
+                详情
+              </el-link>
               <el-popconfirm
                 class="ele-action"
                 title="确定要删除此角色吗?"
@@ -92,6 +92,7 @@
     <AddInventoryDialog
       ref="addInventoryDialogRef"
       :dialogTile="dialogTitle"
+      :id="inventoryId"
       @refreshList="resetForm"
       :isBindPlan="isBindPlan"
     />
@@ -99,6 +100,8 @@
 </template>
 
 <script>
+  import { deleteStocktakingPlan } from '@/api/ruleManagement/plan';
+  import { getInventoryList } from '@/api/ruleManagement/plan';
   import InspectionPoint from '../inspectionPoint';
   import MeasuringSubmit from '../measuringSubmit';
   import Maintenance from '../maintenance';
@@ -115,6 +118,7 @@
     },
     data() {
       return {
+        inventoryId: '',
         activeComp: 'point',
         tabOptions: [
           { key: 'point', name: '巡点检配置' },
@@ -134,21 +138,21 @@
             fixed: 'left'
           },
           {
-            prop: 'code',
+            prop: 'planCode',
             label: '计划单号',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'groupId',
+            prop: 'planName',
             label: '盘点名称',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'enable',
+            prop: 'warehouseName',
             label: '盘点仓库',
             align: 'center',
             showOverflowTooltip: true,
@@ -156,42 +160,48 @@
             minWidth: 110
           },
           {
-            prop: 'name',
+            prop: 'executeGroupName',
             label: '盘点部门',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'type',
+            prop: 'categoryLevelName',
             label: '资产分类',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'cycle',
+            prop: 'ruleName',
             label: '规则名称',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110
           },
           {
-            prop: 'auto',
+            prop: 'autoOrder',
             label: '自动派单',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
+            minWidth: 110,
+            formatter: (row) => {
+              return { 0: '否', 1: '是' }[row.autoOrder];
+            }
           },
           {
-            prop: 'status',
+            prop: 'enable',
             label: '状态',
             align: 'center',
             showOverflowTooltip: true,
-            minWidth: 110
+            minWidth: 110,
+            formatter: (row) => {
+              return { 0: '失效', 1: '生效' }[row.enable];
+            }
           },
           {
-            prop: 'creater',
+            prop: 'createUserName',
             label: '创建人',
             align: 'center',
             showOverflowTooltip: true,
@@ -210,7 +220,7 @@
           {
             columnKey: 'action',
             label: '操作',
-            width: 150,
+            width: 200,
             align: 'center',
             resizable: false,
             slot: 'action',
@@ -243,31 +253,45 @@
     methods: {
       // 重置
       resetForm() {
-        this.$refs.configFormRef.resetFields();
+        this.$refs.inventorySearch.reset();
+        // this.$refs.configFormRef.resetFields();
         // this.searchForm()
       },
       /* 表格数据源 */
       datasource({ page, limit, where, order }) {
-        return pageRoles({ pageNum: page, size: limit, ...where });
+        return getInventoryList({ pageNum: page, size: limit, ...where });
       },
       /* 刷新表格 */
       reload(where) {
         this.$refs.table.reload({ page: 1, where });
       },
+      remove(row) {
+        deleteStocktakingPlan([row.id]).then((res) => {
+          console.log(res);
+          if (res.code == 0) {
+            this.$message.success('删除成功');
+            this.$refs.inventorySearch.reset();
+          }
+        });
+      },
 
       openEdit(row) {
+        if (row) {
+          this.dialogTitle = '修改盘点计划配置';
+          this.inventoryId = row.id;
+        } else {
+          this.dialogTitle = '新增盘点计划配置';
+          this.inventoryId = '';
+        }
         this.isBindPlan = false;
-        this.dialogTitle = '新增盘点计划配置';
         this.$refs.addInventoryDialogRef.dialogVisible = true;
         // this.$store.dispatch('planRules/setAddOrUpdate', 'add')
       },
-      goDetail() {
-        this.$router.push({
-          path: '/rulesManagement/planRules/detail'
-          // query: {
-          //   id
-          // }
-        });
+      goDetail(row) {
+        this.dialogTitle = '盘点计划配置详情';
+        this.inventoryId = row.id;
+        this.isBindPlan = true;
+        this.$refs.addInventoryDialogRef.dialogVisible = true;
       }
     }
   };