Ver código fonte

异常处理新增,物资归还模拟测试

pm 9 meses atrás
pai
commit
a86587c7b7

+ 63 - 0
src/api/mes/material/exception.js

@@ -0,0 +1,63 @@
+import request from '@/utils/request'
+
+// 查询物资信息--分页 /dev-api/iscs/materials/getIsMaterialsPage
+export function MaterialsLoanExceptionPage(query) {
+  return request({
+    url: '/iscs/exception/getIsMaterialsLoanExceptionPage',
+    method: 'get',
+    params: query
+  })
+}
+
+// 新增物资信息 /dev-api/iscs/materials/insertIsMaterials
+export function addMaterials(data) {
+  return request({
+    url: '/iscs/materials/insertIsMaterials',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改物资信息 /dev-api/iscs/materials/updateIsMaterials
+export function updateMaterials(data) {
+  return request({
+    url: '/iscs/materials/updateIsMaterials',
+    method: 'post',
+    data: data
+  })
+}
+
+// 删除物资信息 /dev-api/iscs/materials/deleteIsMaterialsByMaterialsIds
+export function deleteMaterials(data) {
+  return request({
+    url: '/iscs/materials/deleteIsMaterialsByMaterialsIds?materialsIds=' + data,
+    method: 'post',
+  })
+}
+
+// 获取物资详细信息 /dev-api/iscs/materials/selectIsMaterialsById
+export function selectMaterialsById(query) {
+  return request({
+    url: '/iscs/materials/selectIsMaterialsById?materialsId=' + query,
+    method: 'get',
+  })
+}
+
+
+// 物资所属柜 查询物资柜-分页
+export function getIsMaterialsCabinets() {
+  return request({
+    url: '/iscs/cabinet/getIsMaterialsCabinetPage',
+    method: 'get',
+  })
+}
+//绑定物资
+export function updateMaterialsBinding(data) {
+  return request({
+    url: '/iscs/materials/updateMaterialsBinding',
+    method: 'post',
+    data: data
+  })
+}
+
+

+ 10 - 0
src/api/mes/material/information.js

@@ -78,3 +78,13 @@ export function insertIsMaterialsChangeRecord(data) {
     data: data
   })
 }
+// 物资检查记录模拟 新增
+export function insertIsMaterialsCheckRecord(data) {
+  return request({
+    url: '/iscs/check/insertIsMaterialsCheckRecord',
+    method: 'post',
+    data:{
+      list:data
+    }
+  })
+}

+ 302 - 0
src/views/mes/material/Exception/index.vue

@@ -0,0 +1,302 @@
+<template>
+  <div class="app-container">
+    <el-form
+      :model="queryParams"
+      ref="queryForm"
+      size="small"
+      :inline="true"
+      v-show="showSearch"
+      label-width="100px"
+    >
+      <el-form-item label="物资柜" prop="loanFromId">
+        <el-select
+          v-model="queryParams.loanFromId"
+          placeholder="请选择物资柜"
+          clearable
+        >
+          <el-option
+            v-for="dict in cabinets"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </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="restitutionUserName">
+        <el-input
+          v-model="queryParams.restitutionUserName"
+          placeholder="请输入归还人"
+          clearable
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="领取时间">
+        <el-date-picker
+          style="width: 215px"
+          :default-time="['00:00:00', '23:59:59']"
+          v-model="createTime"
+          type="datetimerange"
+          :picker-options="pickerOptions"
+          range-separator="-"
+          start-placeholder="开始日期"
+          end-placeholder="结束日期"
+          align="right"
+          @change="handleClearTime"
+        >
+        </el-date-picker>
+      </el-form-item>
+      <el-form-item label="状态" prop="status">
+        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
+          <el-option
+            v-for="dict in dict.type.material_exception_status"
+            :key="dict.value"
+            :label="dict.label"
+            :value="dict.value"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button
+          v-no-more-click
+          type="primary"
+          icon="el-icon-search"
+          size="mini"
+          @click="handleQuery"
+        >搜索
+        </el-button
+        >
+        <el-button
+          v-no-more-click
+          icon="el-icon-refresh"
+          size="mini"
+          @click="resetQuery"
+        >重置
+        </el-button
+        >
+      </el-form-item>
+    </el-form>
+
+    <el-table
+      v-loading="loading"
+      :data="ExceptionList"
+
+    >
+
+      <el-table-column label="编号" align="center" prop="exceptionId">
+      </el-table-column>
+      <el-table-column label="物资所属柜" align="center" prop="loanFromName" />
+      <el-table-column
+        label="领取时间"
+        align="center"
+        prop="loanTime"
+      >
+      </el-table-column>
+      <el-table-column label="物资名称" align="center" prop="materialsName">
+      </el-table-column>
+      <el-table-column label="归还柜" align="center" prop="restitutionToName">
+      </el-table-column>
+      <el-table-column label="归还人" align="center" prop="restitutionUserName">
+      </el-table-column>
+      <el-table-column label="状态" align="center" prop="status">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.material_exception_status" :value="scope.row.status"/>
+        </template>
+      </el-table-column>
+      <el-table-column label="实际归还时间" align="center" prop="actualRestitutionTime">
+      </el-table-column>
+    </el-table>
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.current"
+      :limit.sync="queryParams.size"
+      @pagination="getList"
+    />
+
+  </div>
+</template>
+
+<script>
+
+import Treeselect from '@riophae/vue-treeselect'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+import Template from '@/views/print/printtemplate/list.vue'
+import { MaterialsLoanExceptionPage } from '@/api/mes/material/exception'
+import { getIsMaterialsCabinets } from '@/api/mes/material/information'
+export default {
+  name: 'Team',
+  components: { Template, Treeselect },
+
+  dicts: ['material_exception_status'],
+  data() {
+    return {
+      //自动生成编码
+      autoGenFlag: false,
+      optType: undefined,
+      // 遮罩层
+      loading: true,
+      // 选中数组
+      ids: [],
+      codes: [],
+      // 非单个禁用
+      single: true,
+      // 非多个禁用
+      multiple: true,
+      // 显示搜索条件
+      showSearch: true,
+      // 总条数
+      total: 0,
+      // 班组表格数据
+      ExceptionList: [],
+      // mars树选项
+      marsOptions: [],
+      // 是否显示弹出层
+      open: false,
+      // 查询参数
+      createTime: '',
+      queryParams: {
+        current: 1,
+        size: 10,
+        loanFromId:'',
+        materialsName:'',
+        restitutionUserName:'',
+        status:'',
+        startTime:'',
+        endTime:'',
+      },
+      title:'',
+      // 表单参数
+      form: {},
+      cabinets: [], //物资所属柜
+      pickerOptions: {
+        shortcuts: [
+          {
+            text: "最近一周",
+            onClick(picker) {
+              const end = new Date();
+              const start = new Date();
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
+              picker.$emit("pick", [start, end]);
+            },
+          },
+          {
+            text: "最近一个月",
+            onClick(picker) {
+              const end = new Date();
+              const start = new Date();
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
+              picker.$emit("pick", [start, end]);
+            },
+          },
+          {
+            text: "最近三个月",
+            onClick(picker) {
+              const end = new Date();
+              const start = new Date();
+              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
+              picker.$emit("pick", [start, end]);
+            },
+          },
+        ],
+      },
+
+    }
+  },
+
+  created() {
+    this.getList()
+    this.materialsCabinets()
+  },
+
+  methods: {
+    formatDate(date) {
+      const year = date.getFullYear().toString().padStart(2, "0");
+      const month = (date.getMonth() + 1).toString().padStart(2, "0");
+      const day = date.getDate().toString().padStart(2, "0");
+      const hours = date.getHours().toString().padStart(2, "0");
+      const minutes = date.getMinutes().toString().padStart(2, "0");
+      const seconds = date.getSeconds().toString().padStart(2, "0");
+
+      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+    },
+    /** 查询物资信息列表 */
+    getList() {
+      this.loading = true
+      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])
+      }
+      const data={
+        ...this.queryParams,
+      }
+      MaterialsLoanExceptionPage(data).then((response) => {
+        console.log(response, '获取物资归还异常allList ')
+        this.ExceptionList = response.data.records
+        this.total = response.data.total
+        this.loading = false
+      })
+    },
+    materialsCabinets() {
+      const data1 = {
+        pasge: 1,
+        size: -1
+      }
+      getIsMaterialsCabinets(data1).then((response) => {
+        if (response?.data?.records) {
+          this.cabinets = response.data.records.map((item) => ({
+            value: item.cabinetId,
+            label: item.cabinetName
+          }))
+        }
+      })
+    },
+// 取消按钮
+    cancel() {
+      this.open = false
+      this.reset()
+    },
+    // 表单重置
+    reset() {
+
+      this.resetForm('form')
+      this.autoGenFlag = false
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.size = 10
+      this.getList()
+    },
+    /** 重置按钮操作 */
+    resetQuery() {
+      this.queryParams.startTime = ''
+      this.queryParams.endTime = ''
+      this.createTime = ''
+      this.resetForm('queryForm')
+      this.handleQuery()
+    },
+    handleClearTime(value){
+      if(value==null){
+        this.queryParams.startTime=null
+        this.queryParams.endTime=null
+      }
+    },
+
+
+
+  }
+}
+</script>
+<style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
+.el-input-width {
+  width: 380px !important;
+
+}
+</style>

+ 225 - 0
src/views/mes/material/Lending/demo4.vue

@@ -0,0 +1,225 @@
+<template>
+  <div>
+    <el-select style="margin: 10px;relative;left:20%;" v-model="queryParams.planId" placeholder="请选择检查计划"
+               @change="handleChangePlan"
+    >
+      <el-option
+
+        v-for="dict in PlanOptions"
+        :key="dict.planId"
+        :label="dict.planName"
+        :value="dict.planId"
+      />
+    </el-select>
+    <div style="width: 1000px;position: relative;left:20%;">
+      <el-table :data="materialList">
+        <!-- 编号列 -->
+        <el-table-column prop="materialsId" label="编号"></el-table-column>
+        <!-- 物资类型列 -->
+        <el-table-column prop="materialsTypeName" label="物资类型"></el-table-column>
+        <!-- 物资名称列 -->
+        <el-table-column prop="materialsName" label="物资名称"></el-table-column>
+        <!-- RFID列 -->
+        <el-table-column prop="materialsRfid" label="RFID"></el-table-column>
+
+        <!-- 正常 -->
+        <el-table-column label="正常">
+          <template slot-scope="scope">
+    <span
+      class="status-icon"
+      :class="{'selected': scope.row.value === 1}"
+      @click="toggleValue(scope.row, 1)"
+    >
+      {{ scope.row.value === 1 ? '✔️' : '✅' }}
+    </span>
+          </template>
+        </el-table-column>
+
+        <!-- 过期 -->
+        <el-table-column label="过期">
+          <template slot-scope="scope">
+    <span
+      class="status-icon"
+      :class="{'selected': scope.row.value === 2}"
+      @click="toggleValue(scope.row, 2)"
+    >
+      {{ scope.row.value === 2 ? '🚷' : '⚠️' }}
+    </span>
+          </template>
+        </el-table-column>
+
+        <!-- 损坏 -->
+        <el-table-column label="损坏">
+          <template slot-scope="scope">
+    <span
+      class="status-icon"
+      :class="{'selected': scope.row.value === 3}"
+      @click="toggleValue(scope.row, 3)"
+    >
+      {{ scope.row.value === 3 ? '🚫' : '🛠️' }}
+    </span>
+          </template>
+        </el-table-column>
+
+
+        <!-- 措施列 -->
+        <el-table-column label="措施">
+          <template slot-scope="scope">
+            <el-input
+              v-model="scope.row.measure"
+              placeholder="请输入措施"
+            >
+            </el-input>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <!-- 提交按钮 -->
+      <el-button @click="submitData" style="margin: 10px;position: relative;left:43%;" type="primary">提交</el-button>
+    </div>
+  </div>
+</template>
+<script>
+import {
+  getIsMaterialsCabinets,
+  listMaterials,
+  selectMaterialsById,
+  updateIsMaterialById, insertIsMaterialsCheckRecord
+} from '@/api/mes/material/information'
+import { listPlan, selectPlanById } from '@/api/mes/material/plan'
+
+export default {
+  name: 'demo4',
+  data() {
+    return {
+      queryParams: {
+        current: 1,
+        size: -1
+      },
+      PlanOptions: null,
+      materialList: [],//检查的物资列表
+      measure: ''
+    }
+  },
+  mounted() {
+    this.getList()
+  },
+  methods: {
+    getList() {
+      listPlan(this.queryParams).then(res => {
+        console.log(res, '检查计划')
+        this.PlanOptions = res.data.records.map(item => {
+          return {
+            planId: item.planId,
+            planName: item.planName
+          }
+        })
+      })
+    },
+    handleChangePlan(value) {
+      selectPlanById(value).then(res => {
+        console.log(res, '拿到选中的检查计划')
+
+        const cabinetIds = res.data.cabinetIds || [] // 确保 cabinetIds 存在
+        if (cabinetIds.length === 0) {
+          console.log('没有 cabinetIds,无需查询')
+          return
+        }
+
+        this.materialList = [] // 每次查询前清空数组
+
+        // 遍历 cabinetIds 并行查询 listMaterials
+        Promise.all(cabinetIds.map(id => this.fetchMaterialsByCabinetId(id)))
+          .then(results => {
+            const allData = results.flat(); // 合并所有返回的数据
+            console.log(allData, '所有查询结果');
+
+            // 添加 value 字段并给它一个默认值
+            allData.forEach(item => {
+              item.value = 0; // 默认设置为正常状态
+            });
+
+            this.materialList = allData; // 保存到 materialList 中
+
+          })
+          .catch(error => {
+            console.error('查询物资数据出错', error)
+          })
+      })
+    },
+
+    // 按单个 cabinetId 查询物资数据
+    fetchMaterialsByCabinetId(id) {
+      const params = { current: 1, size: -1, materialsCabinetId: id }
+      return new Promise((resolve, reject) => {
+        listMaterials(params)
+          .then(res => {
+            console.log(res, `cabinetId: ${id} 的物资数据`)
+            resolve(res.data.records || []) // 确保返回数组
+          })
+          .catch(error => {
+            console.error(`查询 cabinetId: ${id} 的数据失败`, error)
+            reject(error)
+          })
+      })
+    },
+    // 更新状态和原因
+    toggleValue(row, newValue) {
+      console.log(row,'我点击了')
+      // 如果点击的是当前状态,则重置回“正常”状态(value=1)
+      row.value = row.value === newValue ? 1 : newValue;
+
+      // 解析 value 对应的 status 和 reason
+      const mapping = {
+        1: { status: 0, reason: 0 }, // 正常
+        2: { status: 1, reason: 1 }, // 过期
+        3: { status: 1, reason: 2 }, // 损坏
+      };
+
+      row.status = mapping[row.value].status;
+      row.reason = mapping[row.value].reason;
+    },
+
+    // 提交数据
+    submitData() {
+      // 将表格中的数据转换成符合要求的格式
+      const submitData = this.materialList.map(item => ({
+        planId: this.queryParams.planId,
+        materialsId: item.materialsId,
+        materialsTypeName: item.materialsTypeName,
+        materialsName: item.materialsName,
+        materialsRfid: item.materialsRfid,
+        status: item.status,
+        reason: item.reason,
+        measure: item.measure
+      }))
+
+      // 输出最终的数据(此处可以进行实际的提交操作)
+      console.log(submitData)
+      insertIsMaterialsCheckRecord(submitData).then(res => {
+        console.log(res, '新增的结果')
+        if (res.data) {
+          this.$message.success('物资检查完成')
+        } else {
+          this.$message.error('提交失败')
+        }
+      })
+    }
+  }
+//    methods结束
+}
+</script>
+<style scoped lang="scss">
+.status-icon {
+  display: inline-block;
+  font-size: 20px;
+  cursor: pointer;
+  color: gray;
+  transition: color 0.3s;
+}
+
+.status-icon.selected {
+  color: blue;
+}
+
+</style>

+ 0 - 1
src/views/mes/material/replacementrecords/index.vue

@@ -175,7 +175,6 @@
       >
       </el-table-column>
       <el-table-column label="更换时间" align="center" prop="changeDate">
-
       </el-table-column>
 <!--      <el-table-column-->
 <!--        label="操作"-->