ysy 2 роки тому
батько
коміт
034fbb3af4

+ 58 - 0
src/api/ruleManagement/earlyWarning.js

@@ -0,0 +1,58 @@
+import request from '@/utils/request';
+
+// 更新或保存
+export async function saveOrUpdate(data) {
+  const res = await request.post('/main/warnrule/save', data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 生成编码
+export async function getCode(code) {
+  const res = await request.get(`/main/codemanage/getCode/` + code, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取规则列表页
+export async function getList(data) {
+  let par = new URLSearchParams(data);
+  const res = await request.get(`/main/warnrule/page?` + par, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取规则详情
+export async function getDetail(id) {
+  const res = await request.get(`/main/warnrule/getById/` + id, {});
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+/**
+ * 删除事项
+ */
+export async function removeRule(data) {
+  const res = await request.delete('/main/warnrule/delete', { data });
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 获取仓库列表
+export async function getWarehouseList(params) {
+  const res = await request.get('/wms/warehouse/page', params);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 450 - 437
src/views/material/product/components/MaterialAdd.vue

@@ -1,467 +1,480 @@
-
 <template>
-    <ele-modal width="1160px" :visible="visible" v-if="visible" :append-to-body="true" :close-on-click-modal="false"
-        custom-class="ele-dialog-form" title="物料BOM" @update:visible="updateVisible">
-        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
-            <header-title title="物料BOM"> </header-title>
-
-            <el-row>
-
-                <el-col :span="8">
-
-                    <el-form-item label="BOM编码:" prop="code">
-                        <el-input v-model="form.code" disabled />
-                    </el-form-item>
-                </el-col>
-
-                <el-col :span="8">
-                    <el-form-item label="BOM名称:" prop="name">
-                        <el-input placeholder="请输入BOM名称" v-model="form.name" />
-                    </el-form-item>
-                </el-col>
-
-                <el-col :span="8">
-                    <el-form-item label="版本号:" prop="version">
-                        <el-input placeholder="请输入BOM版本号" v-model="form.version" />
-                    </el-form-item>
-                </el-col>
-
-                <el-col :span="8">
-                    <el-form-item label="状态:" prop="status">
-                        <el-select v-model="form.status" placeholder="" filterable>
-                            <el-option v-for="item in statusList" :key="item.value" :label="item.label" :value="item.value">
-                            </el-option>
-                        </el-select>
-                    </el-form-item>
-                </el-col>
-
-
-
-                <el-col :span="8">
-                    <el-form-item label="所属工厂" prop="factoryId">
-                        <factorySelect v-model="form.factoryId" />
-                    </el-form-item>
-                </el-col>
-
-                <el-col :span="8">
-                    <el-form-item label="基本数量" prop="baseCount">
-                        <el-row>
-                            <el-col :span="12">
-                                <el-input placeholder="请输入" v-model.number="form.baseCount">
-                                </el-input></el-col>
-                            <el-col :span="2">&nbsp;</el-col>
-                            <el-col :span="10">
-                                <DictSelection dictName="计量单位" v-model="form.baseCountUnit" />
-                            </el-col>
-                        </el-row>
-                    </el-form-item>
-                </el-col>
-
-            </el-row>
-
+  <ele-modal
+    width="1160px"
+    :visible="visible"
+    v-if="visible"
+    :append-to-body="true"
+    :close-on-click-modal="false"
+    custom-class="ele-dialog-form"
+    title="物料BOM"
+    @update:visible="updateVisible"
+  >
+    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
+      <header-title title="物料BOM"> </header-title>
+
+      <el-row>
+        <el-col :span="8">
+          <el-form-item label="BOM编码:" prop="code">
+            <el-input v-model="form.code" disabled />
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="BOM名称:" prop="name">
+            <el-input placeholder="请输入BOM名称" v-model="form.name" />
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="版本号:" prop="version">
+            <el-input placeholder="请输入BOM版本号" v-model="form.version" />
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="状态:" prop="status">
+            <el-select v-model="form.status" placeholder="" filterable>
+              <el-option
+                v-for="item in statusList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="所属工厂" prop="factoryId">
+            <factorySelect v-model="form.factoryId" />
+          </el-form-item>
+        </el-col>
+
+        <el-col :span="8">
+          <el-form-item label="基本数量" prop="baseCount">
             <el-row>
-                <div class="ele-body">
-                    <ele-pro-table ref="table" :columns="columns" :datasource="tableData" height="calc(100vh - 550px)"
-                        :need-page="false">
-                        <!-- 表头工具栏 -->
-                        <template v-slot:toolbar>
-                            <el-button type="primary" @click="add">添加</el-button>
-                        </template>
-                        <template v-slot:action="{ row, $index }">
-                            <el-link type="primary" @click="handleDel(row, $index)">删除</el-link>
-                        </template>
-                        <template v-slot:subCode="{ row }">
-                            <el-input v-model="row.subCode" placeholder="请输入"></el-input>
-                        </template>
-
-                        <template v-slot:isReworkBom="{ row }">
-                            <el-select v-model="row.isReworkBom">
-                                <el-option v-for="item in isReworkBomList" :key="item.value" :label="item.label"
-                                    :value="item.value">
-                                </el-option>
-                            </el-select>
-                        </template>
-
-                        <template v-slot:unit="{ row }">
-                            <DictSelection dictName="计量单位" v-model="row.unit"></DictSelection>
-                        </template>
-
-
-                        <template v-slot:count="{ row }">
-                            <el-input v-model="row.count" placeholder="请输入" @input="(value) =>
-                            (row.count = value.replace(
-                                /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
-                                '$1$2.$3'
-                            ))
-                                "></el-input>
-                        </template>
-
-
-
-                        <template v-slot:categoryName="{ row, $index }">
-                            <el-input :value="row.categoryName" placeholder="请选择"
-                                @click.native="categorySelect(row, $index)"></el-input>
-                        </template>
-
-
-                        <template v-slot:bomArtFiles="{ row }">
-                            <fileUpload v-model="row.bomArtFiles"  module="main"
-                                :showLib="false" :limit="5" />
-                            <div v-if="row.bomArtFiles && row.bomArtFiles?.length">
-                                <el-link v-for="link in row.bomArtFiles" :key="link.id" type="primary"
-                                    :underline="false" @click="downloadFile(link)">
-                                    {{ link.name }}</el-link>
-                            </div>
-
-                        </template>
-
-                        <template v-slot:remark="{ row }">
-                            <el-input v-model="row.remark" placeholder="请输入"></el-input>
-                        </template>
-
-
-
-                    </ele-pro-table>
-                </div>
-            </el-row>
-
-            <el-row class="rx-cc">
-                <el-button type="primary" size="small" class="ele-btn-icon" @click="save">
-                    保存
-                </el-button>
+              <el-col :span="12">
+                <el-input placeholder="请输入" v-model.number="form.baseCount">
+                </el-input
+              ></el-col>
+              <el-col :span="2">&nbsp;</el-col>
+              <el-col :span="10">
+                <DictSelection
+                  dictName="计量单位"
+                  v-model="form.baseCountUnit"
+                />
+              </el-col>
             </el-row>
-        </el-form>
-        <ProductModal ref="productRefs" @changeProduct='determineChoose' />
-    </ele-modal>
+          </el-form-item>
+        </el-col>
+      </el-row>
+
+      <el-row>
+        <div class="ele-body">
+          <ele-pro-table
+            ref="table"
+            :columns="columns"
+            :datasource="tableData"
+            height="calc(100vh - 550px)"
+            :need-page="false"
+          >
+            <!-- 表头工具栏 -->
+            <template v-slot:toolbar>
+              <el-button type="primary" @click="add">添加</el-button>
+            </template>
+            <template v-slot:action="{ row, $index }">
+              <el-link type="primary" @click="handleDel(row, $index)"
+                >删除</el-link
+              >
+            </template>
+            <template v-slot:subCode="{ row }">
+              <el-input v-model="row.subCode" placeholder="请输入"></el-input>
+            </template>
+
+            <template v-slot:isReworkBom="{ row }">
+              <el-select v-model="row.isReworkBom">
+                <el-option
+                  v-for="item in isReworkBomList"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                >
+                </el-option>
+              </el-select>
+            </template>
+
+            <template v-slot:unit="{ row }">
+              <DictSelection
+                dictName="计量单位"
+                v-model="row.unit"
+              ></DictSelection>
+            </template>
+
+            <template v-slot:count="{ row }">
+              <el-input
+                v-model="row.count"
+                placeholder="请输入"
+                @input="
+                  (value) =>
+                    (row.count = value.replace(
+                      /^(-)*(\d+)\.(\d\d\d\d\d\d).*$/,
+                      '$1$2.$3'
+                    ))
+                "
+              ></el-input>
+            </template>
+
+            <template v-slot:categoryName="{ row, $index }">
+              <el-input
+                :value="row.categoryName"
+                placeholder="请选择"
+                @click.native="categorySelect(row, $index)"
+              ></el-input>
+            </template>
+
+            <template v-slot:bomArtFiles="{ row }">
+              <fileUpload
+                v-model="row.bomArtFiles"
+                module="main"
+                :showLib="false"
+                :limit="5"
+              />
+              <div v-if="row.bomArtFiles && row.bomArtFiles?.length">
+                <el-link
+                  v-for="link in row.bomArtFiles"
+                  :key="link.id"
+                  type="primary"
+                  :underline="false"
+                  @click="downloadFile(link)"
+                >
+                  {{ link.name }}</el-link
+                >
+              </div>
+            </template>
+
+            <template v-slot:remark="{ row }">
+              <el-input v-model="row.remark" placeholder="请输入"></el-input>
+            </template>
+          </ele-pro-table>
+        </div>
+      </el-row>
+
+      <el-row class="rx-cc">
+        <el-button
+          type="primary"
+          size="small"
+          class="ele-btn-icon"
+          @click="save"
+        >
+          保存
+        </el-button>
+      </el-row>
+    </el-form>
+    <ProductModal ref="productRefs" @changeProduct="determineChoose" />
+  </ele-modal>
 </template>
-  
-<script>
 
-import factorySelect from '@/components/CommomSelect/factory-select.vue';
-import { pageList } from '@/api/technology/version/version.js';
-import { getCode } from '@/api/codeManagement/index.js';
-import { bomSave, bomUpdate } from '@/api/material/BOM';
-import ProductModal from '@/components/select/bom/ProductModal.vue'
-import fileUpload from '@/components/upload/fileUpload';
-import {getFile} from "@/api/system/file";
-export default {
+<script>
+  import factorySelect from '@/components/CommomSelect/factory-select.vue';
+  import { pageList } from '@/api/technology/version/version.js';
+  import { getCode } from '@/api/codeManagement/index.js';
+  import { bomSave, bomUpdate } from '@/api/material/BOM';
+  import ProductModal from '@/components/select/bom/ProductModal.vue';
+  import fileUpload from '@/components/upload/fileUpload';
+  import { getFile } from '@/api/system/file';
+  export default {
     components: {
-        factorySelect,
-        ProductModal,
-        fileUpload
+      factorySelect,
+      ProductModal,
+      fileUpload
     },
     props: {
-        // 弹窗是否打开
-        visible: Boolean,
-        // 修改回显的数据
-        categoryId: [String, Number],
-        data: Object,
-        taskId: [String, Number],
+      // 弹窗是否打开
+      visible: Boolean,
+      // 修改回显的数据
+      categoryId: [String, Number],
+      data: Object,
+      taskId: [String, Number]
     },
     data() {
-
-        var baseCountVa = (rule, value, callback) => {
-            if (value == '') {
-                callback(new Error('请输入基本数量'));
-            } else if (this.form.baseCountUnit == '') {
-                callback(new Error('请选择基本数量单位'));
-            } else {
-                callback();
-            }
-        };
-
-        const defaultForm = {
-            id: null,
-            code: '',
-            name: '',
-            version: '1.0',
-            factoryId: '',
-            type: 0,
-            status: '',
-            isReworkBom: 0,
-            baseCount: '',
-            baseCountUnit: '',
-            taskId: '',
-
-
-
-        };
-        return {
-            defaultForm,
-            // 表单数据
-            form: {
-                ...defaultForm
-            },
-
-            removeSubBomIdList: [],
-            versionList: [],
-
-            // 表单验证规则
-            rules: {
-                code: [
-                    { required: true, message: '请输入BOM编码', trigger: 'blur' }
-                ],
-
-                name: [
-                    { required: true, message: '请输入BOM名称', trigger: 'blur' }
-                ],
-
-                version: [
-                    { required: true, message: '请输入BOM版本号', trigger: 'blur' }
-                ],
-
-                status: [
-                    { required: true, message: '请选择状态', trigger: 'change' }
-                ],
-
-
-
-                factoryId: [
-                    { required: true, message: '请输入所属工厂', trigger: 'change' }
-                ],
-
-
-                baseCount: [
-                    { validator: baseCountVa, trigger: 'blur' }
-                ]
-
-            },
-            columns: [
-                {
-                    type: 'index',
-                    width: 55,
-                    align: 'center'
-                },
-                {
-                    label: '子项编号',
-                    prop: 'subCode',
-                    slot: 'subCode',
-                    action: 'subCode'
-                },
-                {
-                    label: '物料名称',
-                    prop: 'categoryName',
-                    slot: 'categoryName',
-                    action: 'categoryName'
-                },
-                {
-                    label: '是否回收料',
-                    prop: 'isReworkBom',
-                    slot: 'isReworkBom',
-                    action: 'isReworkBom'
-
-                },
-                {
-                    label: '物料编码',
-                    prop: 'categoryCode'
-                },
-                {
-                    label: '牌号',
-                    prop: 'brandNum'
-                },
-                {
-                    label: '型号',
-                    prop: 'modelType'
-                },
-                {
-                    label: '数量',
-                    slot: 'count',
-                    action: 'count'
-                },
-                {
-                    label: '单位',
-                    slot: 'unit',
-                    action: 'unit'
-                },
-
-                {
-                    label: '附件',
-                    slot: 'bomArtFiles',
-                    action: 'bomArtFiles',
-                    minWidth: 100,
-                },
-
-                {
-                    label: '备注',
-                    slot: 'remark',
-                    action: 'remark'
-                },
-
-
-
-                {
-                    action: 'action',
-                    slot: 'action',
-                    label: '操作'
-                }
-            ],
-
-            tableData: [],
-            statusList: [
-                { label: '草稿', value: -1 },
-                { label: '失效', value: 0 },
-                { label: '生效', value: 1 }
-            ],
-
-            isReworkBomList: [
-                { label: '否', value: 0 },
-                { label: '是', value: 1 }
-            ],
-
-            // 提交状态
-            loading: false,
-            // 是否是修改
-            isUpdate: false,
-
-
-        };
-    },
-    computed: {
-        // 是否开启响应式布局
-        styleResponsive() {
-            return this.$store.state.theme.styleResponsive;
+      var baseCountVa = (rule, value, callback) => {
+        if (value == '') {
+          callback(new Error('请输入基本数量'));
+        } else if (this.form.baseCountUnit == '') {
+          callback(new Error('请选择基本数量单位'));
+        } else {
+          callback();
         }
-    },
-    methods: {
-        downloadFile(file) {
-      getFile({ objectName: file.storePath }, file.name);
-    },
-
-        handleDel(row, index) {
-            this.tableData.splice(index, 1);
-            if (row?.id) {
-                this.removeSubBomIdList.push(row.id)
-            }
-        },
-
-        add() {
-            let subCode = '0010';
-            if (this.tableData.length) {
-                let max = Math.max(...this.tableData.map((i) => i.subCode)) + 10 + '';
-
-                if (max.length < 4) {
-                    max = new Array(4 - max.length).fill('0').join('') + max;
-                }
-                subCode = max.substring(0, max.length - 1) + '0';
-            }
-
-            this.tableData.push({
-                subCode,
-                categoryId: '',
-                categoryName: '',
-                isReworkBom: 0,
-                brandNum: '',
-                count: '',
-                modelType: '',
-                unit: '',
-                netWeight: '',
-                weightUnit: ''
-            });
-        },
-
-
-
-        async _getCode() {
-            const code = await getCode('bom_code');
-            this.form.code = code;
+      };
+
+      const defaultForm = {
+        id: null,
+        code: '',
+        name: '',
+        version: '1.0',
+        factoryId: '',
+        type: 0,
+        status: '',
+        isReworkBom: 0,
+        baseCount: '',
+        baseCountUnit: '',
+        taskId: ''
+      };
+      return {
+        defaultForm,
+        // 表单数据
+        form: {
+          ...defaultForm
         },
 
-        /* 保存编辑 */
-        save() {
-            this.$refs.form.validate((valid) => {
-                if (!valid) {
-                    return false;
-                }
-
-
-
-
-                if (this.tableData.length == 0) {
-                    this.$message.info('请至少添加一条物料');
-                    return;
-                }
-
-                if (!this.isUpdate) {
-                    delete this.form.id;
-                    this.form['taskId'] = this.taskId
-                }
-
-                const data = {
-                    ...this.form,
-                    removeSubBomIdList: this.removeSubBomIdList,
-                    subDetailList: this.tableData,
-                    categoryId: this.categoryId,
-                };
-
-                this.loading = true;
-
-                const saveOrUpdate = this.isUpdate ? bomUpdate : bomSave;
-                saveOrUpdate(data)
-                    .then((msg) => {
-                        this.loading = false;
-                        this.$message.success(msg);
-                        this.$emit('done', this.form['taskId']);
-                        this.visible = false
-                    })
-                    .catch((e) => {
-                        this.loading = false;
-                    });
-
-            });
-        },
+        removeSubBomIdList: [],
+        versionList: [],
 
+        // 表单验证规则
+        rules: {
+          code: [{ required: true, message: '请输入BOM编码', trigger: 'blur' }],
 
-        categorySelect(row, idx) {
-            // 3  type: 物料组
-            this.$refs.productRefs.open(row, '选择物料', 3, idx)
+          name: [{ required: true, message: '请输入BOM名称', trigger: 'blur' }],
 
-        },
+          version: [
+            { required: true, message: '请输入BOM版本号', trigger: 'blur' }
+          ],
 
-        determineChoose(title, row, idx) {
-            if (title == '选择物料') {
-                this.$set(this.tableData[idx], 'categoryName', row.name)
-                this.$set(this.tableData[idx], 'categoryId', row.id)
-                this.$set(this.tableData[idx], 'categoryCode', row.code)
-                this.$set(this.tableData[idx], 'unit', row.measuringUnit)
-                this.$set(this.tableData[idx], 'weightUnit', row.weightUnit)
-                this.$set(this.tableData[idx], 'brandNum', row.brandNum)
-                this.$set(this.tableData[idx], 'modelType', row.modelType)
+          status: [
+            { required: true, message: '请选择状态', trigger: 'change' }
+          ],
 
-            }
+          factoryId: [
+            { required: true, message: '请输入所属工厂', trigger: 'change' }
+          ],
 
+          baseCount: [{ validator: baseCountVa, trigger: 'blur' }]
         },
+        columns: [
+          {
+            type: 'index',
+            width: 55,
+            align: 'center'
+          },
+          {
+            label: '子项编号',
+            prop: 'subCode',
+            slot: 'subCode',
+            action: 'subCode'
+          },
+          {
+            label: '物料名称',
+            prop: 'categoryName',
+            slot: 'categoryName',
+            action: 'categoryName'
+          },
+          {
+            label: '是否回收料',
+            prop: 'isReworkBom',
+            slot: 'isReworkBom',
+            action: 'isReworkBom'
+          },
+          {
+            label: '物料编码',
+            prop: 'categoryCode'
+          },
+          {
+            label: '牌号',
+            prop: 'brandNum'
+          },
+          {
+            label: '型号',
+            prop: 'modelType'
+          },
+          {
+            label: '数量',
+            slot: 'count',
+            action: 'count'
+          },
+          {
+            label: '单位',
+            slot: 'unit',
+            action: 'unit'
+          },
+
+          {
+            label: '附件',
+            slot: 'bomArtFiles',
+            action: 'bomArtFiles',
+            minWidth: 100
+          },
+
+          {
+            label: '备注',
+            slot: 'remark',
+            action: 'remark'
+          },
+
+          {
+            action: 'action',
+            slot: 'action',
+            label: '操作'
+          }
+        ],
+
+        tableData: [],
+        statusList: [
+          { label: '草稿', value: -1 },
+          { label: '失效', value: 0 },
+          { label: '生效', value: 1 }
+        ],
+
+        isReworkBomList: [
+          { label: '否', value: 0 },
+          { label: '是', value: 1 }
+        ],
+
+        // 提交状态
+        loading: false,
+        // 是否是修改
+        isUpdate: false
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    methods: {
+      downloadFile(file) {
+        getFile({ objectName: file.storePath }, file.name);
+      },
+
+      handleDel(row, index) {
+        this.tableData.splice(index, 1);
+        if (row?.id) {
+          this.removeSubBomIdList.push(row.id);
+        }
+      },
 
+      add() {
+        let subCode = '0010';
+        if (this.tableData.length) {
+          let max = Math.max(...this.tableData.map((i) => i.subCode)) + 10 + '';
 
+          if (max.length < 4) {
+            max = new Array(4 - max.length).fill('0').join('') + max;
+          }
+          subCode = max.substring(0, max.length - 1) + '0';
+        }
 
-        /* 更新visible */
-        updateVisible(value) {
-            this.$emit('update:visible', value);
+        this.tableData.push({
+          subCode,
+          categoryId: '',
+          categoryName: '',
+          isReworkBom: 0,
+          brandNum: '',
+          count: '',
+          modelType: '',
+          unit: '',
+          netWeight: '',
+          weightUnit: ''
+        });
+      },
+
+      async _getCode() {
+        const code = await getCode('bom_code');
+        this.form.code = code;
+      },
+
+      /* 保存编辑 */
+      save() {
+        this.$refs.form.validate((valid) => {
+          if (!valid) {
+            return false;
+          }
+
+          if (this.tableData.length == 0) {
+            this.$message.error('请至少添加一条物料');
+            return;
+          }
+
+          let boolen = this.tableData.every((item) => item.categoryName);
+          if (!boolen) {
+            this.$message.error('请完善物料名称!');
+            return false;
+          }
+
+          if (!this.isUpdate) {
+            delete this.form.id;
+            this.form['taskId'] = this.taskId;
+          }
+
+          const data = {
+            ...this.form,
+            removeSubBomIdList: this.removeSubBomIdList,
+            subDetailList: this.tableData,
+            categoryId: this.categoryId
+          };
+
+          this.loading = true;
+
+          const saveOrUpdate = this.isUpdate ? bomUpdate : bomSave;
+          saveOrUpdate(data)
+            .then((msg) => {
+              this.loading = false;
+              this.$message.success(msg);
+              this.$emit('done', this.form['taskId']);
+              this.visible = false;
+            })
+            .catch((e) => {
+              this.loading = false;
+            });
+        });
+      },
+
+      categorySelect(row, idx) {
+        // 3  type: 物料组
+        this.$refs.productRefs.open(row, '选择物料', 3, idx);
+      },
+
+      determineChoose(title, row, idx) {
+        if (title == '选择物料') {
+          this.$set(this.tableData[idx], 'categoryName', row.name);
+          this.$set(this.tableData[idx], 'categoryId', row.id);
+          this.$set(this.tableData[idx], 'categoryCode', row.code);
+          this.$set(this.tableData[idx], 'unit', row.measuringUnit);
+          this.$set(this.tableData[idx], 'weightUnit', row.weightUnit);
+          this.$set(this.tableData[idx], 'brandNum', row.brandNum);
+          this.$set(this.tableData[idx], 'modelType', row.modelType);
         }
+      },
+
+      /* 更新visible */
+      updateVisible(value) {
+        this.$emit('update:visible', value);
+      }
     },
 
     watch: {
-        async visible(visible) {
-            if (visible) {
-                this._getCode()
-
-                this.removeSubBomIdList = []
-              
-                if (this.data) {
-                    this.tableData = this.data.subDetailList
-                    this.$util.assignObject(this.form, {
-                        ...this.data
-                    });
-                    this.isUpdate = true
-                } else {
-                    this.tableData = []
-                    this.isUpdate = false
-                }
-            } else {
-                this.$refs.form.clearValidate();
-                this.form = { ...this.defaultForm };
-            }
+      async visible(visible) {
+        if (visible) {
+          this._getCode();
+
+          this.removeSubBomIdList = [];
+
+          if (this.data) {
+            this.tableData = this.data.subDetailList;
+            this.$util.assignObject(this.form, {
+              ...this.data
+            });
+            this.isUpdate = true;
+          } else {
+            this.tableData = [];
+            this.isUpdate = false;
+          }
+        } else {
+          this.$refs.form.clearValidate();
+          this.form = { ...this.defaultForm };
         }
+      }
     }
-};
+  };
 </script>
-  

+ 1 - 1
src/views/material/product/detail.vue

@@ -120,7 +120,7 @@
           </el-col>
           <el-col :span="8">
             <el-form-item label="负责人">
-              <personSelect ref="directorRef" v-model="form.deptId" @selfChange="handleDirectorChange" :init="false" />
+              <personSelect ref="directorRef" v-model="form.deptIds" @selfChange="handleDirectorChange" :init="false" />
             </el-form-item>
           </el-col>
         </el-row>

+ 489 - 0
src/views/rulesManagement/earlyWarningRules/components/matter-add.vue

@@ -0,0 +1,489 @@
+<template>
+  <div class="matter-add">
+    <ele-modal :title="dialogTitle" :visible.sync="addMatterDialog" :before-close="handleClose"
+      :close-on-click-modal="false" :close-on-press-escape="false" width="80%">
+      <el-form :model="formData" v-loading="dialogLoading" ref="contentConfigForm" label-width="100px"
+        :show-message="false" :rules="contentConfigFormRules">
+        <el-row>
+          <el-col :span="7">
+            <el-form-item label="规则编码" prop="name">
+              <el-input v-model="formData.code" size="small" :disabled="true"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="规则名称" prop="name">
+              <el-input v-model="formData.name" placeholder="请输入" size="small" :disabled="isBindPlan"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="规则类型" prop="ruleType">
+              <DictSelection dictName="规则类型" clearable v-model="formData.ruleType">
+              </DictSelection>
+            </el-form-item>
+          </el-col>
+          <el-col :span="5">
+            <el-form-item label="状态" prop="status" label-width="70px">
+              <el-switch v-model="formData.status" active-text="生效" inactive-text="失效" :active-value="1"
+                :inactive-value="0">
+              </el-switch>
+            </el-form-item>
+          </el-col>
+
+
+        </el-row>
+   
+
+
+        <el-row>
+        <el-col :span="8">
+            <el-form-item label="预警值" prop="warningValue">
+              <el-input @input="(value) =>
+                (formData.warningValue = value.replace(
+                  /^(0+)|[^\d]+/g,
+                  ''
+                ))
+                " v-model.number="formData.warningValue" placeholder="请输入" style="width: 160px;"></el-input>
+
+
+              <DictSelection style="width: 160px;margin-left: 10px;" dictName="时间单位" clearable
+                v-model="formData.warningUnit">
+              </DictSelection>
+
+
+            </el-form-item>
+          </el-col>
+
+          <el-col :span="6">
+            <el-form-item label="紧急程度" prop="urgent">
+            <DictSelection
+              dictName="紧急程度"
+              clearable
+              filterable
+              v-model="formData.urgent"
+            >
+            </DictSelection>
+          </el-form-item>
+            </el-col>
+          </el-row>
+
+          <el-row>
+            <el-col :span="24">
+            <el-form-item label="周期" prop="cycleValue">
+              <rule-cycle ref="cycleMultipleRef" :formData="formData" :pageType="pageType" :isBindPlan="isBindPlan" />
+            </el-form-item>
+          </el-col>
+            </el-row>
+
+
+        <el-table ref="multipleTable" v-if="formData.ruleType !== 4" :data="formData.ruleItems" tooltip-effect="dark"
+          style="width: 95%; margin: auto" border :header-cell-style="{ background: '#F0F3F3' }">
+          <el-table-column type="index" width="100" align="center">
+            <template slot="header">
+              <el-button type="text" @click="addItem" icon="el-icon-plus" :disabled="isBindPlan">新增</el-button>
+            </template>
+          </el-table-column>
+          <el-table-column prop="name" label="事项" width="300">
+            <template slot-scope="scope">
+              <el-form-item :prop="'ruleItems.' + scope.$index + '.name'" label-width="0"
+                :rules="contentConfigFormRules.name">
+                <span v-if="scope.row.readonly">{{ scope.row.name }}</span>
+                <el-input v-if="!scope.row.readonly" size="small" placeholder="请输入" v-model="scope.row.name"
+                  :disabled="isBindPlan"></el-input>
+              </el-form-item>
+            </template>
+          </el-table-column>
+          <el-table-column prop="content" label="内容" width="500">
+            <template slot-scope="scope">
+              <el-form-item :prop="'ruleItems.' + scope.$index + '.content'" label-width="0"
+                :rules="contentConfigFormRules.content">
+                <span v-if="scope.row.readonly">{{ scope.row.content }}</span>
+                <el-input v-if="!scope.row.readonly" size="small" placeholder="请输入" v-model="scope.row.content"
+                  :disabled="isBindPlan"></el-input>
+              </el-form-item>
+            </template>
+          </el-table-column>
+
+          <el-table-column prop="norm" label="标准">
+            <template slot-scope="scope">
+              <el-form-item :prop="'ruleItems.' + scope.$index + '.norm'" label-width="0"
+                :rules="contentConfigFormRules.norm">
+                <span v-if="scope.row.readonly">{{ scope.row.norm }}</span>
+                <el-input v-if="!scope.row.readonly" size="small" placeholder="请输入" v-model="scope.row.norm"
+                  :disabled="isBindPlan"></el-input>
+              </el-form-item>
+            </template>
+          </el-table-column>
+
+          <el-table-column label="操作">
+            <template slot-scope="scope">
+              <el-button type="text" @click="delItem(scope.$index)" size="small" :disabled="isBindPlan">删除</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-form>
+      <template v-slot:footer>
+        <el-button @click="handleClose">取消</el-button>
+        <el-button type="primary" @click="dataKeep"> 保存 </el-button>
+      </template>
+    </ele-modal>
+  </div>
+</template>
+<script>
+import RuleCycle from './rule-cycle';
+import { deepClone } from '@/utils/index';
+import {
+  saveOrUpdate,
+  getCode,
+  getDetail
+} from '@/api/ruleManagement/earlyWarning';
+
+export default {
+  components: { RuleCycle },
+  props: {
+    pageType: {
+      type: String,
+      default: ''
+    },
+    infoData: {
+      type: Object,
+      default: () => {
+        return {};
+      }
+    },
+    dialogTitle: {
+      type: String,
+      default: '新建规则'
+    },
+    dialogLoading: {
+      type: Boolean,
+      default: () => {
+        return false;
+      }
+    }
+  },
+  data() {
+    // 默认表单数据
+    const defaultForm = {
+      code: '',
+      name: '',
+      ruleType: '1',
+      status: 1,
+      warningValue: null,
+      cycleValue: undefined,
+      cycleType: 1,
+      contentImage: {},
+      ruleCycleList: [], // 规则周期日期值
+      ruleItems: [
+        {
+          name: '', // 巡点检事项
+          content: '', // 巡点检内容
+          norm: '' // 巡点检标准
+        }
+      ]
+    };
+    return {
+      addMatterDialog: false,
+      cycleValue: '',
+      uploadList: [],
+      formData: {},
+      contentConfigFormRules: {
+        name: [
+          { required: true, message: '请输入规则名称', trigger: 'blur' }
+        ],
+        ruleType: [
+          { required: true, message: '请选择规则类型', trigger: 'change' }
+        ],
+        warningValue: [
+          { required: true, message: '请输入预警值', trigger: 'blur' }
+        ],
+        // contentImage: [
+        //   { required: false, message: '请上传图片', trigger: 'blur' }
+        // ],
+        status: [{ required: true }],
+        name: [
+          { required: true, message: '请输入巡点检事项', trigger: 'blur' }
+        ],
+        content: [
+          { required: true, message: '请输入巡点检内容', trigger: 'blur' }
+        ],
+        norm: [
+          { required: true, message: '请输入巡点检标准', trigger: 'blur' }
+        ]
+      },
+      isBindPlan: false
+    };
+  },
+  watch: {},
+  methods: {
+    openDialog(row, type) {
+      this.addMatterDialog = true;
+      if (type != 'add') {
+        this.getRuleInfo(row.id, type);
+      } else {
+        this.formData = { ...this.defaultForm };
+        this.$set(this.formData, 'status', 1);
+        this.$set(this.formData, 'ruleType', '1');
+        console.log('this.formData---------', this.formData);
+        this.$refs.contentConfigForm &&
+          this.$refs.contentConfigForm.resetFields();
+      }
+      if (type != 'edit') {
+        this.getOrderCode();
+      }
+    },
+
+    async getRuleInfo(id, type) {
+      const data = await getDetail(id);
+      this.formData = data;
+      this.formData.ruleType = JSON.stringify(this.formData.ruleType);
+      this.$set(this.formData, 'urgent', JSON.stringify(this.formData.urgent));
+      if (type == 'clone') {
+        delete this.formData.id;
+      }
+    },
+
+    async getOrderCode() {
+      const data = await getCode('warn_rule_code');
+      this.$set(this.formData, 'code', data);
+    },
+
+    handleClose() {
+      this.addMatterDialog = false;
+      this.$emit('handleClose');
+    },
+    addItem() {
+      if (this.formData.ruleItems) {
+        this.formData.ruleItems.push({
+          name: '', // 巡点检事项
+          content: '', // 巡点检内容
+          norm: '', // 巡点检标准
+
+          readonly: false
+        });
+      } else {
+        let arr = [
+          {
+            name: '', // 巡点检事项
+            content: '', // 巡点检内容
+            norm: '' // 巡点检标准
+          }
+        ];
+        this.$set(this.formData, 'ruleItems', arr);
+        // this.formData.ruleItems =
+      }
+    },
+    saveItem(index, row) {
+      this.$nextTick(() => {
+        let flag = false;
+        let name = row.name;
+        let content = row.content;
+        let norm = row.norm;
+        flag = name && content && norm;
+        this.$refs.contentConfigForm.validate((valid) => {
+          if (valid || flag) {
+            this.$set(this.formData.ruleItems[index], 'readonly', true);
+          }
+        });
+      });
+    },
+    upload(data) {
+      if (data && data[0]?.accessUrl) {
+        this.formData.contentImage = data;
+      } else {
+        this.formData.contentImage = {};
+      }
+      this.$nextTick(() => {
+        this.$refs.contentConfigForm.validateField('contentImage');
+      });
+      console.log(this.formData.contentImage);
+    },
+    editItem(index) {
+      this.$nextTick(() => {
+        this.$set(this.formData.ruleItems[index], 'readonly', false);
+      });
+    },
+    delItem(index) {
+      this.formData.ruleItems.splice(index, 1);
+    },
+
+    // 保存
+    dataKeep() {
+      let form = deepClone(this.formData);
+      console.log(this.$refs.cycleMultipleRef);
+      form.cycle = this.$refs.cycleMultipleRef.ruleCycleList;
+      console.log(form);
+      switch (form.cycleType) {
+        case 1:
+          if (form.cycle[0].minute === '') {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 2:
+          if (form.cycle[0].hour === '' || form.cycle[0].minute === '') {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 4:
+          if (
+            form.cycle[0].day === '' ||
+            form.cycle[0].hour === '' ||
+            form.cycle[0].minute === ''
+          ) {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 5:
+          if (
+            form.cycle[0].month === '' ||
+            form.cycle[0].day === '' ||
+            form.cycle[0].hour === '' ||
+            form.cycle[0].minute === ''
+          ) {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 11:
+          let flg = false;
+          form.cycle.map((item, index) => {
+            if (item.hour === '' || item.minute === '') {
+              flg = true;
+            }
+          });
+          if (flg) {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 13:
+          let flag = false;
+          form.cycle.map((item, index) => {
+            if (item.day === '' || item.hour === '') {
+              flag = true;
+            }
+          });
+          if (flag) {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+        case 14:
+          let fla = false;
+          form.cycle.map((item, index) => {
+            if (item.month === '' || item.day === '' || item.hour === '') {
+              fla = true;
+            }
+          });
+          if (fla) {
+            this.$message.warning('周期信息需补充完整!');
+            return;
+          }
+          break;
+      }
+      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.error('请添加事项内容!');
+      }
+    }
+  }
+};
+</script>
+<style scoped lang="scss">
+.operationGuide_box {
+  width: 100%;
+  height: 50px;
+  display: flex;
+  overflow: hidden;
+  cursor: pointer;
+
+  .left_content {
+    flex: 0 0 200px;
+    padding: 10px;
+    box-sizing: border-box;
+    border: 1px solid #c0c4cc;
+    border-radius: 10px;
+    margin-right: 10px;
+    overflow-y: auto;
+  }
+
+  .right_content {
+    flex: 1;
+    padding: 10px;
+    box-sizing: border-box;
+    border: 1px solid #c0c4cc;
+    border-radius: 10px;
+    overflow-y: auto;
+  }
+}
+
+.form-ipt {
+  width: 310px;
+}
+
+.details-div {
+  font-size: 14px;
+  padding-left: 40px;
+
+  .details-div-title {
+    display: flex;
+    justify-content: space-between;
+
+    span {
+      padding-top: 8px;
+    }
+  }
+}
+
+.zw-container {
+  height: 450px;
+}
+
+.page-footer-btn {
+  margin: 20px 0;
+  text-align: center;
+}
+
+// .app-container {
+::v-deep .el-form-item {
+  margin-bottom: 14px;
+}
+
+::v-deep .el-table__body-wrapper {
+  .el-form-item {
+    margin-bottom: 0;
+  }
+}
+
+::v-deep .el-form-item__error {
+  padding-top: 0;
+}
+
+.cycle_value {
+  ::v-deep .el-input__inner {
+    text-align: center;
+  }
+}
+
+// }</style>

+ 121 - 0
src/views/rulesManagement/earlyWarningRules/components/matter-search.vue

@@ -0,0 +1,121 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="80px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <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.name" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="规则状态:">
+          <DictSelection dictName="规则状态" clearable v-model="where.status">
+          </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.code" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="创建时间:">
+          <el-date-picker
+            v-model="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="规则类型:">
+          <DictSelection dictName="规则类型" clearable v-model="where.type">
+          </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.userName" placeholder="请输入" />
+        </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>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+
+  export default {
+    data() {
+      // 默认表单数据
+      const defaultWhere = {
+        name: '',
+        code: '',
+        userName: '',
+        type: '',
+        status: '',
+        startTime: '',
+        endTime: ''
+      };
+      return {
+        // 表单数据
+        where: { ...defaultWhere },
+        treeData: [],
+        time: []
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    created() {},
+    methods: {
+      /* 搜索 */
+      search() {
+        if (this.time.length) {
+          this.where.startTime = this.time[0];
+          this.where.endTime = this.time[1];
+        }
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset() {
+        this.time = [];
+        this.where = { ...this.defaultWhere };
+        this.search();
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  .ele-form-actions {
+    display: flex;
+    align-items: center;
+    justify-content: flex-end;
+  }
+</style>

+ 99 - 0
src/views/rulesManagement/earlyWarningRules/components/product-search.vue

@@ -0,0 +1,99 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="10">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="编码">
+          <el-input clearable v-model="where.code" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="名称">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="型号">
+          <el-input clearable v-model="where.modelType" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 4 } : { md: 4 }">
+        <div class="ele-form-actions">
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh"
+            class="ele-btn-icon"
+            size="medium"
+            >重置</el-button
+          >
+        </div>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data() {
+      // 默认表单数据
+      const defaultWhere = {
+        name: '',
+        code: '',
+        modelType: ''
+      };
+      return {
+        defaultWhere,
+        // 表单数据
+        where: { ...defaultWhere },
+        treeData: []
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    created() {},
+    methods: {
+      /* 搜索 */
+      search() {
+        if (this.where.appType === 0) {
+          this.where.appType = '';
+        }
+        this.$emit('search', this.where);
+      },
+      /*  重置 */
+      reset() {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      },
+      reset2() {
+        this.where = { ...this.defaultWhere };
+      }
+    }
+  };
+</script>
+
+<style>
+  .ele-form-actions {
+    display: inline-block;
+    transform: translate(0);
+    transition: all;
+  }
+</style>

+ 471 - 0
src/views/rulesManagement/earlyWarningRules/components/rule-cycle.vue

@@ -0,0 +1,471 @@
+<template>
+  <div>
+    <el-row :gutter="8" v-if="pageType">
+      <el-col :span="2">
+        <el-input
+          @input="
+            (value) =>
+              (formData.cycleValue = value.replace(/^(0+)|[^\d]+/g, ''))
+          "
+          class="cycle_value"
+          size="small"
+          v-model.number="formData.cycleValue"
+          @change="cycleValueChange"
+          placeholder="请输入"
+          :disabled="isBindPlan"
+        ></el-input>
+      </el-col>
+      <el-col :span="3">
+        <el-select
+          v-model="formData.cycleType"
+          size="small"
+          @change="handleCycleTypeChange"
+          :disabled="isBindPlan"
+        >
+          <el-option
+            v-for="item in cycleOpt"
+            :key="item.code"
+            :label="item.label"
+            :value="item.code"
+          ></el-option>
+        </el-select>
+      </el-col>
+
+      <el-col :span="8" v-if="[1, 2, 4, 5].includes(formData.cycleType)">
+        <div
+          v-for="(item, index) in ruleCycleList"
+          :key="index"
+          class="cycle01_box"
+        >
+          <el-input
+            v-model.number="item.month"
+            size="small"
+            oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
+            @input="(e) => inputMonth(e, index)"
+            v-if="[5].includes(formData.cycleType)"
+            :disabled="isBindPlan"
+          >
+            <template #suffix>月</template>
+          </el-input>
+
+          <el-input
+            v-model.number="item.day"
+            size="small"
+            oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
+            @input="(e) => inputDay(e, index)"
+            v-if="[4, 5].includes(formData.cycleType)"
+            :disabled="isBindPlan"
+          >
+            <template #suffix>日</template>
+          </el-input>
+
+          <el-input
+            v-model.number="item.hour"
+            size="small"
+            oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+            @input="(e) => inputHour(e, index)"
+            v-if="[2, 4, 5].includes(formData.cycleType)"
+            :disabled="isBindPlan"
+          >
+            <template #suffix>时</template>
+          </el-input>
+
+          <el-input
+            v-model.number="item.minute"
+            size="small"
+            oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+            @input="(e) => inputMinute(e, index)"
+            :disabled="isBindPlan"
+          >
+            <template #suffix>分</template>
+          </el-input>
+        </div>
+      </el-col>
+    </el-row>
+    <el-row v-else>
+      <el-col :span="24" class="cycle_time_column">
+        <span style="margin-right: 20px"
+          >{{ formData.cycleValue }}{{ cycleOptObj[formData.cycleType] }}</span
+        >
+        <div v-if="[1, 2, 4, 5].includes(formData.cycleType)">
+          <span v-if="[5].includes(formData.cycleType)"
+            >{{ ruleCycleList[0].month }}月</span
+          >
+          <span v-if="[4, 5].includes(formData.cycleType)"
+            >{{ ruleCycleList[0].day }}日</span
+          >
+          <span v-if="[2, 4, 5].includes(formData.cycleType)"
+            >{{ ruleCycleList[0].hour }}时</span
+          >
+          <span>{{ ruleCycleList[0].minute }}分</span>
+        </div>
+      </el-col>
+    </el-row>
+
+    <!-- 根据周期类型展示时间组件 11,12,13,14 -->
+    <div>
+      <!-- 次/天 -->
+      <el-row :gutter="20" v-if="formData.cycleType === 11">
+        <el-col
+          v-for="(item, index) in ruleCycleList"
+          :key="index"
+          :span="6"
+          class="cycle_item"
+        >
+          <span>第{{ index + 1 }}次</span>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.hour"
+              size="small"
+              placeholder="时"
+              oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+              @input="(e) => inputHour(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>时</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.hour }}时</div>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.minute"
+              size="small"
+              oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+              @input="(e) => inputMinute(e, index)"
+              placeholder="分"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>分</template>
+            </el-input>
+          </div>
+          <div v-else>
+            {{ item.minute > 9 ? item.minute : '0' + item.minute }}分
+          </div>
+        </el-col>
+      </el-row>
+      <!-- 次/周 -->
+      <el-row :gutter="20" v-else-if="formData.cycleType === 12">
+        <el-col
+          v-for="(item, index) in ruleCycleList"
+          :key="index"
+          :span="6"
+          class="cycle_item"
+        >
+          <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-option
+                v-for="item in weekList"
+                :key="item.value"
+                :value="item.value"
+                :label="item.label"
+              ></el-option> </el-select
+            >周
+          </div>
+          <div v-else>{{ item.week }}</div>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.hour"
+              size="small"
+              placeholder="时"
+              oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+              @input="(e) => inputHour(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>时</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.hour }}时</div>
+        </el-col>
+      </el-row>
+      <!-- 次/月 -->
+      <el-row :gutter="20" v-else-if="formData.cycleType === 13">
+        <el-col
+          v-for="(item, index) in ruleCycleList"
+          :key="index"
+          :span="6"
+          class="cycle_item"
+        >
+          <span>第{{ index + 1 }}次</span>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.day"
+              size="small"
+              placeholder="日"
+              oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
+              @input="(e) => inputDay(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>日</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.day }}日</div>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.hour"
+              size="small"
+              placeholder="时"
+              oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+              @input="(e) => inputHour(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>时</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.hour }}</div>
+        </el-col>
+      </el-row>
+      <!-- 次/年 -->
+      <el-row :gutter="20" v-else-if="formData.cycleType === 14">
+        <el-col
+          v-for="(item, index) in ruleCycleList"
+          :key="index"
+          :span="6"
+          class="cycle_item"
+        >
+          <span>第{{ index + 1 }}次</span>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.month"
+              size="small"
+              placeholder="月"
+              oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
+              @input="(e) => inputMonth(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>月</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.month }}月</div>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.day"
+              size="small"
+              placeholder="日"
+              oninput="value = value.replace(/^(0+)|[^\d]+/g,'')"
+              @input="(e) => inputDay(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>日</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.day }}日</div>
+          <div class="cycle_sub_item" v-if="pageType">
+            <el-input
+              v-model.number="item.hour"
+              size="small"
+              placeholder="时"
+              oninput="value = value.replace(/^0+(\d)|[^\d]+/g,'')"
+              @input="(e) => inputHour(e, index)"
+              :disabled="isBindPlan"
+            >
+              <template #suffix>时</template>
+            </el-input>
+          </div>
+          <div v-else>{{ item.hour }}时</div>
+        </el-col>
+      </el-row>
+    </div>
+  </div>
+</template>
+
+<script>
+  export default {
+    props: {
+      formData: {
+        type: Object,
+        default: () => {
+          return {};
+        }
+      },
+      // 编辑edit和新增add
+      pageType: {
+        type: String,
+        default: ''
+      },
+
+      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) {
+        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 = [];
+
+        // 次在后
+        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 (cycleType02.includes(this.formData.cycleType)) {
+          for (let i = 0; i < val; i++) {
+            this.ruleCycleList.push({
+              month: 1, // 周期月
+              day: 1, // 周期日
+              hour: 0, // 周期时
+              minute: 0 // 周期分
+            });
+          }
+        }
+
+        // 时/次
+        if (this.formData.cycleType === 1) {
+          this.ruleCycleList.forEach((item) => {
+            delete item.month;
+            delete item.day;
+            delete item.hour;
+          });
+        }
+
+        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;
+      display: flex;
+      align-items: center;
+    }
+  }
+  .cycle01_box {
+    display: flex;
+    ::v-deep .el-input {
+      width: 80px;
+    }
+  }
+  .cycle_time_column {
+    display: flex;
+  }
+</style>

+ 283 - 0
src/views/rulesManagement/earlyWarningRules/details.vue

@@ -0,0 +1,283 @@
+<template>
+  <div class="page">
+    <el-form label-width="140px">
+      <div class="content-detail">
+        <div class="basic-details">
+          <div class="basic-details-title">
+            <span class="border-span">基本信息</span>
+          </div>
+          <el-row>
+            <el-col :span="6">
+              <el-form-item label="规则编码">
+                <span> {{ infoData.code }} </span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="规则名称">
+                <span> {{ infoData.name }} </span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="规则类型">
+                <span>
+                  {{ getDictValue('规则类型', infoData.ruleType) }}
+                </span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="状态">
+                <span class="primary-text" v-if="infoData.status">生效</span>
+                <span class="danger-text" v-else-if="!infoData.status"
+                  >失效</span
+                >
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="创建人">
+                <span> {{ infoData.createUserName }} </span>
+              </el-form-item>
+            </el-col>
+            <el-col :span="6">
+              <el-form-item label="创建时间">
+                <span> {{ infoData.createTime }} </span>
+              </el-form-item>
+            </el-col>
+          </el-row>
+
+          <el-row>
+            <el-col :span="8">
+              <el-form-item label="预警值" prop="warningValue">
+                <span>{{ infoData.warningValue }}</span>
+
+                <DictSelection
+                  style="width: 120px"
+                  dictName="时间单位"
+                  disabled
+                  v-model="infoData.warningUnit"
+                >
+                </DictSelection>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="6">
+              <el-form-item label="紧急程度" prop="urgent">
+                <DictSelection
+                  dictName="紧急程度"
+                  disabled
+                  v-model="infoData.urgent"
+                >
+                </DictSelection>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row>
+          <el-col :span="24">
+            <el-form-item label="巡点检周期">
+              <rule-cycle :formData="infoData" />
+            </el-form-item>
+          </el-col>
+          </el-row>
+          
+        </div>
+        <template v-if="!(infoData.ruleType && infoData.ruleType.code == 4)">
+          <div class="basic-details-title">
+            <span class="border-span">内容配置</span>
+          </div>
+          <el-table
+            ref="multipleTable"
+            :data="tableData"
+            tooltip-effect="dark"
+            style="width: 100%"
+            border
+            :header-cell-style="{ background: '#F0F3F3' }"
+          >
+            <el-table-column type="index" label="序号" width="60" />
+            <el-table-column prop="name" label="检测事项" />
+            <el-table-column prop="content" label="检测内容" />
+            <el-table-column prop="norm" label="检测标准" />
+          </el-table>
+        </template>
+      </div>
+
+      <div class="content-detail" v-show="num == 2"></div>
+    </el-form>
+  </div>
+</template>
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import RuleCycle from './components/rule-cycle';
+  import { getDetail } from '@/api/ruleManagement/earlyWarning';
+  export default {
+    mixins: [dictMixins],
+    components: { RuleCycle },
+    data() {
+      return {
+        num: 1,
+        dialogVisible: false,
+        infoData: {},
+        form: {},
+        type: [],
+        tableData: [],
+        ruleTypeObj: {
+          1: '巡点检规则',
+          2: '保养规则',
+          4: '盘点规则'
+        }
+      };
+    },
+    async created() {
+      this.getInfo();
+      this.requestDict('规则类型');
+    },
+    methods: {
+      delete() {},
+      // 点击切换事件
+      tab(index) {
+        this.num = index;
+      },
+
+      // 表格数据
+      async getInfo() {
+        const data = await getDetail(this.$route.query.id);
+        this.tableData = data.ruleItems;
+        this.infoData = data;
+      }
+    }
+  };
+</script>
+<style lang="scss" scoped>
+  .page {
+    padding: 10px;
+  }
+  .page-title {
+    background: #fff;
+    font-size: 18px;
+    padding: 6px 20px;
+    font-weight: 500;
+    .page-title-div {
+      margin: 5px 0;
+      height: 30px;
+      line-height: 30px;
+      border-bottom: 1px solid #eaeefb;
+      .title-div-no {
+        margin-left: 10px;
+        font-weight: 400;
+        color: #909090;
+        font-size: 14px;
+      }
+    }
+  }
+  .page-data {
+    padding-top: 10px;
+  }
+  .content-detail {
+    background: #fff;
+    padding: 20px;
+  }
+  .flows {
+    .flow-left {
+      width: 156px;
+      height: 70px;
+      border: 1px dashed #ccc;
+      padding: 10px;
+    }
+    .row {
+      margin-top: 13px;
+    }
+  }
+  .basic-details-title {
+    margin-bottom: 12px;
+    margin-top: 20px;
+    border-bottom: 1px solid #1890ff;
+    padding-bottom: 8px;
+    display: flex;
+    justify-content: space-between;
+  }
+  .basic-details-title .border-span {
+    height: 18px;
+    font-size: 16px;
+    border-left: 4px solid #1890ff;
+    padding-left: 8px;
+
+    font-weight: 500;
+  }
+  .heade-right {
+    // float: right;
+    .heade-right-content {
+      margin-right: 12px;
+      font-size: 14px;
+      display: inline-block;
+      .content-key {
+        color: #3e3e3e;
+        margin-right: 12px;
+        font-weight: 500;
+      }
+      .content-value {
+        color: #000;
+      }
+    }
+  }
+  .list-title {
+    font-size: 14px;
+    color: #3e3e3e;
+    margin: 10px 0px;
+  }
+  .goods {
+    background: #a30014;
+    border: 1px solid #a30014;
+  }
+  .details-title {
+    display: inline-block;
+    color: #6e6e6e;
+    font-size: 14px;
+    font-weight: bold;
+    margin-right: 13px;
+    width: 70px;
+    text-align: right;
+  }
+  .details-con {
+    color: #3e3e3e;
+    font-size: 14px;
+  }
+  .detailed-tab {
+    margin-left: 10px;
+    margin-top: 10px;
+  }
+  ::v-deep .el-form-item--medium .el-form-item__label {
+    color: #6e6e6e;
+    font-size: 14px;
+    font-weight: bold;
+  }
+  .warehouse {
+    display: block;
+    border-bottom: 1px solid #eaeefb;
+    padding: 10px 0;
+  }
+  .box-card {
+    .store-box {
+      width: 80%;
+      .store-box-span {
+        display: inline-block;
+        font-size: 14px;
+        height: 50px;
+        width: 50px;
+        text-align: center;
+        line-height: 50px;
+        color: #fff;
+        margin: 2px;
+      }
+    }
+  }
+  .vacant {
+    background: #3196fb;
+  }
+  .inUse {
+    background: #157a2c;
+  }
+  .invalid {
+    background: #cccccc;
+  }
+  .full {
+    background: #cc3300;
+  }
+</style>

+ 232 - 0
src/views/rulesManagement/earlyWarningRules/index.vue

@@ -0,0 +1,232 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never" v-loading="loading">
+      <matter-search @search="reload"> </matter-search>
+      <!-- 数据表格 -->
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        cache-key="systemRoleTable13"
+      >
+        <!-- 表头工具栏 -->
+        <template v-slot:toolbar>
+          <el-button
+            size="small"
+            type="primary"
+            icon="el-icon-plus"
+            class="ele-btn-icon"
+            @click="openEdit('add')"
+          >
+            新建
+          </el-button>
+        </template>
+        <!-- 编码列 -->
+        <template v-slot:code="{ row }">
+          <el-link type="primary" :underline="false" @click="goDetail(row)">
+            {{ row.code }}
+          </el-link>
+        </template>
+
+        <template v-slot:warningValue="{ row }"> 11 </template>
+
+        <!-- 操作列 -->
+        <template v-slot:action="{ row }">
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-finished"
+            @click="openEdit('clone', row)"
+          >
+            克隆
+          </el-link>
+          <el-link
+            type="primary"
+            :underline="false"
+            icon="el-icon-edit"
+            @click="openEdit('edit', row)"
+          >
+            修改
+          </el-link>
+          <el-popconfirm
+            class="ele-action"
+            title="确定要删除此角色吗?"
+            @confirm="remove(row)"
+          >
+            <template v-slot:reference>
+              <el-link type="danger" :underline="false" icon="el-icon-delete">
+                删除
+              </el-link>
+            </template>
+          </el-popconfirm>
+        </template>
+      </ele-pro-table>
+    </el-card>
+
+    <!-- 新建或编辑弹窗 -->
+    <matter-add
+      ref="addMatterRulesRef"
+      :pageType="pageType"
+      :dialogTitle="dialogTitle"
+      @done="reload"
+    />
+  </div>
+</template>
+
+<script>
+  import MatterSearch from './components/matter-search.vue';
+  import MatterAdd from './components/matter-add.vue';
+  import {
+    getList,
+    getDetail,
+    removeRule
+  } from '@/api/ruleManagement/earlyWarning';
+  import dictMixins from '@/mixins/dictMixins';
+  export default {
+    mixins: [dictMixins],
+    components: {
+      MatterSearch,
+      MatterAdd
+    },
+    data() {
+      return {
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '规则编码',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'code'
+          },
+          {
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.getDictValue('规则状态', _row.status);
+            }
+          },
+          {
+            prop: 'ruleType',
+            label: '规则类型',
+            align: 'center',
+            showOverflowTooltip: true,
+            slot: 'enable',
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.getDictValue('规则类型', _row.ruleType);
+            }
+          },
+          {
+            prop: 'name',
+            label: '规则名称',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+
+          {
+            prop: 'warningValue',
+            label: '预警值',
+            align: 'center',
+            minWidth: 110,
+            slot: 'warningValue'
+          },
+
+          {
+            prop: 'cycle',
+            label: '周期',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.getDictValue('规则周期', _row.cycleType);
+            }
+          },
+          {
+            prop: 'createUserName',
+            label: '创建人',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110
+          },
+          {
+            prop: 'createTime',
+            label: '创建时间',
+            align: 'center',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            formatter: (_row, _column, cellValue) => {
+              return this.$util.toDateString(cellValue);
+            }
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 230,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true
+          }
+        ],
+        // 加载状态
+        loading: false,
+        pageType: 'add',
+        dialogTitle: ''
+      };
+    },
+    computed: {},
+    created() {
+      this.requestDict('规则周期');
+      this.requestDict('规则类型');
+      this.requestDict('规则状态');
+    },
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, limit, where, order }) {
+        return getList({ pageNum: page, size: limit, ...where });
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where });
+      },
+
+      remove(row) {
+        removeRule([row.id]).then((res) => {
+          this.$message.success('删除成功!');
+          this.reload();
+        });
+      },
+
+      openEdit(type, row) {
+        this.pageType = type;
+        this.dialogTitle =
+          type == 'add' ? '新建规则' : type == 'edit' ? '编辑规则' : '克隆规则';
+        this.$refs.addMatterRulesRef.openDialog(row, type);
+      },
+
+      goDetail({ id }) {
+        this.$router.push({
+          path: '/rulesManagement/earlyWarningRules/details',
+          query: { id }
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped></style>

+ 3 - 3
src/views/system/organization/components/org-user-edit.vue

@@ -127,7 +127,7 @@ export default {
   data() {
     const defaultForm = {
       id: null,
-      deptId: [
+      deptIds: [
       ],
 
       groupId: null,
@@ -226,7 +226,7 @@ export default {
 
         if (this.deptTree.length > 0) {
           this.deptTree.forEach(i => {
-            this.form.deptId.push(i[i.length - 1])
+            this.form.deptIds.push(i[i.length - 1])
           })
 
           this.form['deptTree'] = JSON.stringify(this.deptTree)
@@ -279,7 +279,7 @@ export default {
             this.form = { ...res };
 
             this.deptTree = []
-            this.form.deptId = []
+            this.form.deptIds = []
             if (this.form.deptTree) {
               this.deptTree = JSON.parse(this.form.deptTree)
             }

+ 35 - 5
src/views/system/role/components/role-edit.vue

@@ -17,11 +17,15 @@
         />
       </el-form-item>
       <el-form-item label="组织ID:" prop="groupId">
-        <el-input
+        <ele-tree-select
           clearable
-          :maxlength="20"
-          v-model="form.groupId"
-          placeholder="请输入组织ID"
+          :data="organizationList"
+          label-key="name"
+          value-key="id"
+          default-expand-all
+          placeholder="请选择所属机构"
+            v-model="form.groupId"
+       
         />
       </el-form-item>
       <el-form-item label="启用状态:" prop="enable">
@@ -46,7 +50,10 @@
 
 <script>
   import { addRole, putRoles } from '@/api/system/role';
+  import {
+    listOrganizations,
 
+  } from '@/api/system/organization';
   export default {
     props: {
       // 弹窗是否打开
@@ -84,10 +91,32 @@
         // 提交状态
         loading: false,
         // 是否是修改
-        isUpdate: false
+        isUpdate: false,
+
+        organizationList: []
       };
     },
     methods: {
+
+      
+      query() {
+        this.loading = true;
+        listOrganizations()
+          .then((list) => {
+            this.loading = false;
+            this.organizationList = this.$util.toTreeData({
+              data: list,
+              idField: 'id',
+              parentIdField: 'parentId'
+            });
+      
+          })
+          .catch((e) => {
+            this.loading = false;
+        
+          });
+      },
+
       /* 保存编辑 */
       save() {
         this.$refs.form.validate((valid) => {
@@ -118,6 +147,7 @@
     watch: {
       visible(visible) {
         if (visible) {
+          this.query()
           if (this.data != null) {
             // this.$util.assignObject(this.form, this.data);
             // this.form = this.data;

+ 3 - 3
src/views/system/role/components/role-search.vue

@@ -13,8 +13,8 @@
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
-        <el-form-item label="组织ID:">
-          <el-input clearable v-model="where.groupId" placeholder="请输入" />
+        <el-form-item label="组织名称:">
+          <el-input clearable v-model="where.groupName" placeholder="请输入" />
         </el-form-item>
       </el-col>
       <!-- <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
@@ -45,7 +45,7 @@
       // 默认表单数据
       const defaultWhere = {
         name: '',
-        groupId: ''
+        groupName: ''
       };
       return {
         // 表单数据

+ 2 - 2
src/views/system/role/index.vue

@@ -129,8 +129,8 @@
             minWidth: 110
           },
           {
-            prop: 'groupId',
-            label: '组织ID',
+            prop: 'groupName',
+            label: '组织名称',
             align: 'center',
             showOverflowTooltip: true,
             minWidth: 110