Browse Source

物资检查计划

wangyani 9 months ago
parent
commit
1f08cdc0a7
2 changed files with 277 additions and 220 deletions
  1. 49 0
      src/api/mes/material/checkPlan.js
  2. 228 220
      src/views/mes/material/inspectionplan/index.vue

+ 49 - 0
src/api/mes/material/checkPlan.js

@@ -0,0 +1,49 @@
+import request from '@/utils/request'
+
+// 查询物资检查计划列表-分页   /dev-api/iscs/plan/getIsMaterialsCheckPlanPage
+export function getPlanList(query) {
+    return request({
+        url: '/iscs/plan/getIsMaterialsCheckPlanPage',
+        method: 'get',
+        params: query
+    })
+
+}
+
+
+// 新增物资检查计划   /dev-api/iscs/plan/insertIsMaterialsCheckPlan
+export function addPlan(data) {
+    return request({
+        url: '/iscs/plan/insertIsMaterialsCheckPlan',
+        method: 'post',
+        data: data
+    })
+}
+
+
+// 删除物资检查计划  /dev-api/iscs/plan/deleteIsMaterialsCheckPlanByPlanIds
+export function deletePlan() {
+    return request({
+        url: '/iscs/plan/deleteIsMaterialsCheckPlanByPlanIds?=planIds' + planIds,
+        method: 'post'
+    })
+}
+
+
+// 修改物资检查计划  ​/dev-api​/iscs​/plan​/updateIsMaterialsCheckPlan
+export function updatePlan(data) {
+    return request({
+        url: '​/iscs​/plan​/updateIsMaterialsCheckPlan',
+        method: 'post',
+        data: data
+    })
+}
+
+// 获取物资检查计划详细信息   /dev-api/iscs/plan/updateIsMaterialsCheckPlan
+export function getPlanDetail(query) {
+    return request({
+        url: '/iscs/plan/updateIsMaterialsCheckPlan',
+        method: 'get',
+        params: query
+    })
+}

+ 228 - 220
src/views/mes/material/inspectionplan/index.vue

@@ -25,15 +25,8 @@
           placeholder="选择岗位"
         />
       </el-form-item>
-      <el-form-item label="检察员" prop="materialsName">
-        <el-input
-          v-model="queryParams.materialsName"
-          placeholder="请输入检察员"
-          clearable
-          @keyup.enter.native="handleQuery"
-        />
-      </el-form-item>
-      <el-form-item label="计划日期">
+
+      <!-- <el-form-item label="计划日期">
         <el-date-picker
           style="width: 300px"
           :default-time="['00:00:00', '23:59:59']"
@@ -46,6 +39,14 @@
           align="right"
         >
         </el-date-picker>
+      </el-form-item> -->
+      <el-form-item label="检察员" prop="materialsName">
+        <el-input
+          v-model="queryParams.materialsName"
+          placeholder="请输入检察员"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
       </el-form-item>
       <el-form-item label="状态" prop="status">
         <el-select v-model="queryParams.status" placeholder="状态">
@@ -65,17 +66,15 @@
           icon="el-icon-search"
           size="mini"
           @click="handleQuery"
-        >搜索
-        </el-button
-        >
+          >搜索
+        </el-button>
         <el-button
           v-no-more-click
           icon="el-icon-refresh"
           size="mini"
           @click="resetQuery"
-        >重置
-        </el-button
-        >
+          >重置
+        </el-button>
       </el-form-item>
     </el-form>
 
@@ -88,11 +87,11 @@
           icon="el-icon-plus"
           size="mini"
           @click="handleAdd"
-          v-hasPermi="['iscs:task:add']"
-        >新增
+          v-hasPermi="['iscs:plan:add']"
+          >新增
         </el-button>
       </el-col>
-      <el-col :span="1.5">
+      <!-- <el-col :span="1.5">
         <el-button
           v-no-more-click
           type="danger"
@@ -101,10 +100,10 @@
           size="mini"
           :disabled="multiple"
           @click="handleDelete"
-          v-hasPermi="['iscs:task:remove']"
-        >批量删除
+          v-hasPermi="['iscs:plan:remove']"
+          >批量删除
         </el-button>
-      </el-col>
+      </el-col> -->
       <right-toolbar
         :showSearch.sync="showSearch"
         @queryTable="getList"
@@ -116,35 +115,35 @@
       :data="materialsList"
       @selection-change="handleSelectionChange"
     >
-      <el-table-column type="selection" width="55" align="center"/>
+      <!-- <el-table-column type="selection" width="55" align="center" /> -->
       <el-table-column label="计划编号" align="center" prop="checkId">
       </el-table-column>
       <el-table-column label="计划名称" align="center" prop="checkName">
       </el-table-column>
-      <el-table-column label="岗位" align="center" prop="workstationId">
+      <el-table-column label="检查物资柜" align="center" prop="workstationId">
       </el-table-column>
-      <el-table-column label="检察员" align="center" prop="userIdStr">
+
+      <!--      <el-table-column label="巡检物资柜" align="center" prop="cabinetIdStr">-->
+      <!--        <template slot-scope="scope">-->
+      <!--          <el-tag type="danger">{{ getCabinetName(scope.row.cabinetIdStr) }}</el-tag>-->
+      <!--        </template>-->
+      <!--      </el-table-column>-->
+      <el-table-column label="计划日期" align="center" prop="cron">
         <template slot-scope="scope">
-          <el-tag>{{ getUserName(scope.row.userIdStr) }}</el-tag>
+          {{ cronDescription(scope.row.cron) }}
         </template>
       </el-table-column>
-<!--      <el-table-column label="巡检物资柜" align="center" prop="cabinetIdStr">-->
-<!--        <template slot-scope="scope">-->
-<!--          <el-tag type="danger">{{ getCabinetName(scope.row.cabinetIdStr) }}</el-tag>-->
-<!--        </template>-->
-<!--      </el-table-column>-->
-      <el-table-column
-        label="计划日期"
-        align="center"
-        prop="cron"
-      >
+      <el-table-column label="检察员" align="center" prop="userIdStr">
         <template slot-scope="scope">
-          {{ cronDescription(scope.row.cron) }}
+          <el-tag>{{ getUserName(scope.row.userIdStr) }}</el-tag>
         </template>
       </el-table-column>
       <el-table-column label="状态" align="center" prop="status">
         <template slot-scope="scope">
-          <dict-tag :options="dict.type.checking_status" :value="scope.row.status"/>
+          <dict-tag
+            :options="dict.type.checking_status"
+            :value="scope.row.status"
+          />
         </template>
       </el-table-column>
       <el-table-column label="检查记录" align="center" prop="status">
@@ -164,26 +163,26 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
-            v-hasPermi="['iscs:task:query']"
-          >编辑
+            v-hasPermi="['iscs:plan:query']"
+            >编辑
           </el-button>
-          <el-button
+          <!-- <el-button
             v-no-more-click
             size="mini"
             type="text"
             icon="el-icon-edit"
             @click="handleResult(scope.row)"
             v-hasPermi="['iscs:task:result']"
-          >结果记录
-          </el-button>
+            >结果记录
+          </el-button> -->
           <el-button
             v-no-more-click
             size="mini"
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
-            v-hasPermi="['iscs:task:remove']"
-          >删除
+            v-hasPermi="['iscs:plan:remove']"
+            >删除
           </el-button>
         </template>
       </el-table-column>
@@ -203,10 +202,7 @@
       </div>
       <el-form ref="form" :model="form" :rules="rules" label-width="110px">
         <el-form-item label="任务名称" prop="checkName">
-          <el-input
-            v-model="form.checkName"
-            placeholder="请输入任务名称"
-          />
+          <el-input v-model="form.checkName" placeholder="请输入任务名称" />
         </el-form-item>
         <el-form-item label="检查物资柜" prop="cabinetIdStr">
           <el-select
@@ -242,7 +238,7 @@
         </el-form-item>
         <el-form-item label="检查时间频率" prop="cron">
           <el-input v-model="form.cron" placeholder="请点击生成表达式">
-            {{form.co}}
+            {{ form.co }}
             <template slot="append">
               <el-button v-no-more-click type="primary" @click="handleShowCron">
                 生成表达式
@@ -255,15 +251,24 @@
 
       <div slot="footer" class="dialog-footer">
         <el-button v-no-more-click type="primary" @click="submitForm"
-        >确 定
-        </el-button
-        >
+          >确 定
+        </el-button>
         <el-button v-no-more-click @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
     <!--    检查日期表达式工具-->
-    <el-dialog title="Cron表达式生成器" :visible.sync="openCron" append-to-body destroy-on-close class="scrollbar">
-      <crontab @hide="openCron=false" @fill="crontabFill" :expression="expression"></crontab>
+    <el-dialog
+      title="Cron表达式生成器"
+      :visible.sync="openCron"
+      append-to-body
+      destroy-on-close
+      class="scrollbar"
+    >
+      <crontab
+        @hide="openCron = false"
+        @fill="crontabFill"
+        :expression="expression"
+      ></crontab>
     </el-dialog>
     <!-- 检查结果-->
     <el-dialog title="检查结果记录" :visible.sync="ResultVisible" width="50%">
@@ -274,21 +279,21 @@
         <p>巡检人:{{ inspector }}</p>
       </div>
       <el-table :data="items" border>
-        <el-table-column prop="name" label="物资名称" width="200"/>
-        <el-table-column prop="id" label="物资编号" width="150"/>
+        <el-table-column prop="name" label="物资名称" width="200" />
+        <el-table-column prop="id" label="物资编号" width="150" />
         <el-table-column label="物资状态" width="200">
           <template slot-scope="scope">
             <el-select v-model="scope.row.status" placeholder="请选择">
-              <el-option label="正常" value="正常"/>
-              <el-option label="破损" value="破损"/>
-              <el-option label="丢失" value="丢失"/>
-              <el-option label="过期" value="过期"/>
+              <el-option label="正常" value="正常" />
+              <el-option label="破损" value="破损" />
+              <el-option label="丢失" value="丢失" />
+              <el-option label="过期" value="过期" />
             </el-select>
           </template>
         </el-table-column>
         <el-table-column label="备注">
           <template slot-scope="scope">
-            <el-input v-model="scope.row.comment" placeholder="备注信息"/>
+            <el-input v-model="scope.row.comment" placeholder="备注信息" />
           </template>
         </el-table-column>
       </el-table>
@@ -301,26 +306,25 @@
 </template>
 
 <script>
+import { getPlanPerson, getIsCheckTaskCabinets } from "@/api/mes/material/plan";
 import {
-  listCheckTask,
-  addCheckTask,
-  getPlanPerson,
-  updateCheckTask,
-  deleteCheckTask,
-  selectCheckTaskById,
-  getIsCheckTaskCabinets
-} from '@/api/mes/material/plan'
-import { genCode } from '@/api/system/autocode/rule'
-import Crontab from '@/components/Crontab/index.vue'
-import cronstrue from 'cronstrue/i18n';
-import Treeselect from '@riophae/vue-treeselect'
-import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-import { listMarsDept } from '@/api/system/marsdept'
+  getPlanList,
+  addPlan,
+  deletePlan,
+  updatePlan,
+  getPlanDetail,
+} from "@/api/mes/material/checkPlan";
+import { genCode } from "@/api/system/autocode/rule";
+import Crontab from "@/components/Crontab/index.vue";
+import cronstrue from "cronstrue/i18n";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import { listMarsDept } from "@/api/system/marsdept";
 
 export default {
-  name: 'Team',
+  name: "Team",
   components: { Treeselect, Crontab },
-  dicts: ['material_status','checking_status'],
+  dicts: ["material_status", "checking_status"],
   data() {
     return {
       //自动生成编码
@@ -344,59 +348,58 @@ export default {
       // mars树选项
       marsOptions: [],
       // 弹出层标题
-      title: '',
+      title: "",
       // 是否显示弹出层
       open: false,
       // 是否显示Cron表达式弹出层
       openCron: false,
       // 传入的表达式
-      expression: '',
+      expression: "",
       // 查询参数
-      createTime: '',
+      createTime: "",
       queryParams: {
-        pages: 1,
+        current: 1,
         size: 10,
-        materialsCode: null,
-        materialsName: null,
-        loanState: null,
-        materialsCabinetId: null,
-        materialsTypeId: null,
-        startTime: '',
-        endTime: ''
+        // materialsCode: null,
+        // materialsName: null,
+        // loanState: null,
+        // materialsCabinetId: null,
+        // materialsTypeId: null,
+        // startTime: "",
+        // endTime: "",
       },
 
       // 查询参数
       queryParamsCabinets: {
         current: 1,
-        size: -1
+        size: -1,
       },
 
       // 表单参数
       form: {},
 
       cabinets: [], //物资所属柜
-      planPersonOption: [],// 检查人员
+      planPersonOption: [], // 检查人员
       // 表单校验
       rules: {
         userIdStr: [
-          { required: true, message: '人员不能为空', trigger: 'blur' }
+          { required: true, message: "人员不能为空", trigger: "blur" },
         ],
         checkName: [
-          { required: true, message: '任务名称不能为空', trigger: 'blur' }
+          { required: true, message: "任务名称不能为空", trigger: "blur" },
         ],
         cron: [
-          { required: true, message: '检查时间频率不能为空', trigger: 'blur' }
-        ]
-
+          { required: true, message: "检查时间频率不能为空", trigger: "blur" },
+        ],
       },
-      ResultVisible: false,//检查结果弹窗标志
-      planName: '每月物资检查计划',
-      cabinetId: '柜子001',
-      inspectionDate: '2024-12-15',
-      inspector: '张三',
+      ResultVisible: false, //检查结果弹窗标志
+      planName: "每月物资检查计划",
+      cabinetId: "柜子001",
+      inspectionDate: "2024-12-15",
+      inspector: "张三",
       items: [
-        { name: '安全帽', id: 'A001', status: '正常', comment: '' },
-        { name: '消防器材', id: 'B002', status: '正常', comment: '' }
+        { name: "安全帽", id: "A001", status: "正常", comment: "" },
+        { name: "消防器材", id: "B002", status: "正常", comment: "" },
       ],
       pickerOptions: {
         shortcuts: [
@@ -429,235 +432,240 @@ export default {
           },
         ],
       },
-    }
+    };
   },
   created() {
-    this.getList()
-    this.materialsCabinets()
+    this.getList();
+    this.materialsCabinets();
   },
 
   methods: {
-    cronDescription(cron){
-      return cronstrue.toString(cron, { locale: 'zh_CN' })
+    cronDescription(cron) {
+      return cronstrue.toString(cron, { locale: "zh_CN" });
     },
     /** 查询物资信息列表 */
     getList() {
-      this.loading = true
+      this.loading = true;
       // 格式化日期并更新 queryParams
       if (Array.isArray(this.createTime) && this.createTime.length === 2) {
-        this.queryParams.startTime = this.formatDate(this.createTime[0])
-        this.queryParams.endTime = this.formatDate(this.createTime[1])
+        this.queryParams.startTime = this.formatDate(this.createTime[0]);
+        this.queryParams.endTime = this.formatDate(this.createTime[1]);
       }
-      listCheckTask(this.queryParams).then((response) => {
-        console.log(response, '获取物资信息allList ')
-        this.materialsList = response.data.records
-        this.total = response.data.total
+      getPlanList(this.queryParams).then((response) => {
+        console.log(response, "获取物资信息allList ");
+        this.materialsList = response.data.records;
+        this.total = response.data.total;
         this.machinerytypeList = this.handleTree(
           response.data.records,
-          'materialsTypeId',
-          'parentId',
-          'children'
-        )
-        this.loading = false
-      })
-
+          "materialsTypeId",
+          "parentId",
+          "children"
+        );
+        this.loading = false;
+      });
     },
-// 物资所属柜
+    // 物资所属柜
     materialsCabinets() {
       getIsCheckTaskCabinets(this.queryParamsCabinets).then((response) => {
         if (response?.data?.records) {
           // 提取 cabinetId 和 cabinetName
           this.cabinets = response.data.records.map((item) => ({
             value: item.cabinetId,
-            label: item.cabinetName
-          }))
+            label: item.cabinetName,
+          }));
         }
         // 岗位查询
         const data1 = {
           pasge: 1,
-          size: -1
-        }
+          size: -1,
+        };
         listMarsDept(data1).then((response) => {
-          this.marsOptions = this.handleTree(response.data.records,"workstationId","parentId")
-        })
-      })
+          this.marsOptions = this.handleTree(
+            response.data.records,
+            "workstationId",
+            "parentId"
+          );
+        });
+      });
       // 巡检人员
       const data = {
         pageNum: 1,
-        pageSize: 99999
-      }
+        pageSize: 99999,
+      };
       getPlanPerson(data).then((res) => {
-        console.log(res, '巡检人员信息')
+        console.log(res, "巡检人员信息");
         this.planPersonOption = res.rows.map((item) => {
           return {
             label: item.nickName,
-            value: item.userId
-          }
-        })
-      })
+            value: item.userId,
+          };
+        });
+      });
     },
     normalizer(node) {
       if (node.children && !node.children.length) {
-        delete node.children
+        delete node.children;
       }
       return {
         id: node.workstationId,
         label: node.workstationName,
-        children: node.children
-      }
+        children: node.children,
+      };
     },
     // 取消按钮
     cancel() {
-      this.open = false
-      this.reset()
+      this.open = false;
+      this.reset();
     },
     // 表单重置
     reset() {
       this.form = {
-        cron: undefined
-      }
-      this.resetForm('form')
-      this.autoGenFlag = false
+        cron: undefined,
+      };
+      this.resetForm("form");
+      this.autoGenFlag = false;
     },
     /** 搜索按钮操作 */
     handleQuery() {
-      this.queryParams.pages = 1
-      this.getList()
+      this.queryParams.pages = 1;
+      this.getList();
     },
     /** 重置按钮操作 */
     resetQuery() {
-
-      this.resetForm('queryForm')
-      this.handleQuery()
+      this.resetForm("queryForm");
+      this.handleQuery();
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map((item) => item.checkId)
-      this.single = selection.length !== 1
-      this.multiple = !selection.length
+      this.ids = selection.map((item) => item.checkId);
+      this.single = selection.length !== 1;
+      this.multiple = !selection.length;
     },
 
     /** 新增按钮操作 */
     handleAdd() {
-      this.reset()
-      this.open = true
-      this.title = '新增检查计划'
-      this.optType = 'add'
-
+      this.reset();
+      this.open = true;
+      this.title = "新增检查计划";
+      this.optType = "add";
     },
 
     /** 修改按钮操作 */
     handleUpdate(row) {
-      this.reset()
-      selectCheckTaskById(row.checkId).then((response) => {
-        this.form = response.data
-        this.form.userIdStr = response.data.userIdStr.split(',')
-        this.form.cabinetIdStr = response.data.cabinetIdStr.split(',')
-        this.open = true
-        this.title = '编辑检查计划'
-        this.optType = 'edit'
-      })
+      this.reset();
+      getPlanDetail(row.checkId).then((response) => {
+        this.form = response.data;
+        this.form.userIdStr = response.data.userIdStr.split(",");
+        this.form.cabinetIdStr = response.data.cabinetIdStr.split(",");
+        this.open = true;
+        this.title = "编辑检查计划";
+        this.optType = "edit";
+      });
     },
 
     /** cron表达式按钮操作 */
     handleShowCron() {
-      this.expression = this.form.cron
-      this.openCron = true
+      this.expression = this.form.cron;
+      this.openCron = true;
     },
     /** 确定后回传值 */
     crontabFill(value) {
-      this.form.cron = value
+      this.form.cron = value;
     },
     /** 提交按钮 */
     submitForm() {
-      this.$refs['form'].validate((valid) => {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
           if (this.form.checkId != null) {
             const data = {
               checkId: this.form.checkId,
               checkName: this.form.checkName,
-              cabinetIdStr: this.form.cabinetIdStr.join(','),
-              userIdStr: this.form.userIdStr.join(','),
-              cron: this.form.cron
-            }
-            updateCheckTask(data).then((response) => {
-              console.log(response, '修改返回')
-              this.$modal.msgSuccess('修改成功')
-              this.open = false
-              this.getList()
-            })
+              cabinetIdStr: this.form.cabinetIdStr.join(","),
+              userIdStr: this.form.userIdStr.join(","),
+              cron: this.form.cron,
+            };
+            updatePlan(data).then((response) => {
+              console.log(response, "修改返回");
+              this.$modal.msgSuccess("修改成功");
+              this.open = false;
+              this.getList();
+            });
           } else {
             const data = {
-
               checkName: this.form.checkName,
-              cabinetIdStr: this.form.cabinetIdStr.join(','),
-              userIdStr: this.form.userIdStr.join(','),
-              cron: this.form.cron
-            }
+              cabinetIdStr: this.form.cabinetIdStr.join(","),
+              userIdStr: this.form.userIdStr.join(","),
+              cron: this.form.cron,
+            };
             // console.log(data,'新增的参数');
-            addCheckTask(data).then((response) => {
-              console.log(response, '新增返回')
-              this.$modal.msgSuccess('新增成功')
-              this.open = false
-              this.getList()
-            })
+            addPlan(data).then((response) => {
+              console.log(response, "新增返回");
+              this.$modal.msgSuccess("新增成功");
+              this.open = false;
+              this.getList();
+            });
           }
         }
-      })
+      });
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      const checkIds = row.checkId || this.ids
+      const checkIds = row.checkId || this.ids;
 
       this.$modal
         .confirm('是否确认删除编号为"' + checkIds + '"的数据项?')
-        .then(function() {
-          return deleteCheckTask(checkIds)
+        .then(function () {
+          return deletePlan(checkIds);
         })
         .then(() => {
-          this.getList()
-          this.$modal.msgSuccess('删除成功')
-        })
-        .catch(() => {
+          this.getList();
+          this.$modal.msgSuccess("删除成功");
         })
+        .catch(() => {});
     },
 
     //   检查结果 弹窗打开函数
     handleResult() {
-      this.ResultVisible = true
+      this.ResultVisible = true;
     },
 
     // 检查结果确认按钮
     saveResults() {
       // 提交检查结果逻辑
-      console.log(this.items)
-      this.dialogVisible = false
+      console.log(this.items);
+      this.dialogVisible = false;
     },
     // 表格转换用户名
     getUserName(userIdStr) {
-      if (!userIdStr) return ''
-      const userIds = userIdStr.split(',').map(Number)
-      return userIds.map(userId => {
-        const user = this.planPersonOption.find(option => option.value == userId)
-        return user ? user.label : ''
-      }).join(', ')
+      if (!userIdStr) return "";
+      const userIds = userIdStr.split(",").map(Number);
+      return userIds
+        .map((userId) => {
+          const user = this.planPersonOption.find(
+            (option) => option.value == userId
+          );
+          return user ? user.label : "";
+        })
+        .join(", ");
     },
     // 表格转换物资柜子
     getCabinetName(cabinetIdStr) {
-      if (!cabinetIdStr) return ''
-      const cabinetIds = cabinetIdStr.split(',').map(Number)
-      return cabinetIds.map(cabinetId => {
-        const cabinet = this.cabinets.find(option => option.value == cabinetId)
-        return cabinet ? cabinet.label : ''
-      }).join(', ')
-    }
-
-  }
-}
+      if (!cabinetIdStr) return "";
+      const cabinetIds = cabinetIdStr.split(",").map(Number);
+      return cabinetIds
+        .map((cabinetId) => {
+          const cabinet = this.cabinets.find(
+            (option) => option.value == cabinetId
+          );
+          return cabinet ? cabinet.label : "";
+        })
+        .join(", ");
+    },
+  },
+};
 </script>
 <style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
 .el-input-width {
   width: 380px !important;
-
 }
 </style>