This commit is contained in:
		
							parent
							
								
									5d9c290a4b
								
							
						
					
					
						commit
						b1d13bf1b5
					
				| 
						 | 
				
			
			@ -122,3 +122,29 @@ export function addWsMaInfoData(data) {
 | 
			
		|||
    data: data,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 小工具编码信息列表--删除
 | 
			
		||||
export function delGadget(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/material/wsMaInfo/delGadget',
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    data: data,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//查看机具类型管理列表详细信息
 | 
			
		||||
export function getGadgetInfo(id) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/material/wsMaInfo/getGadgetInfo/'+ id,
 | 
			
		||||
    method: 'get',
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 小工具编码信息列表--修改
 | 
			
		||||
export function updateGadgetInfo(data) {
 | 
			
		||||
  return request({
 | 
			
		||||
    url: '/material/wsMaInfo/updateGadgetInfo',
 | 
			
		||||
    method: 'post',
 | 
			
		||||
    data: data,
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,6 +43,22 @@
 | 
			
		|||
      <el-table-column label="下次检验时间" align="center" prop="nextCheckTime" show-overflow-tooltip />
 | 
			
		||||
      <el-table-column label="检修员" align="center" prop="repairMan" show-overflow-tooltip/>
 | 
			
		||||
      <el-table-column label="检验员" align="center" prop="checkMan" show-overflow-tooltip/>
 | 
			
		||||
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
 | 
			
		||||
        <template slot-scope="scope">
 | 
			
		||||
          <el-button
 | 
			
		||||
            size="mini"
 | 
			
		||||
            type="text"
 | 
			
		||||
            icon="el-icon-edit"
 | 
			
		||||
            @click="handleEdit(scope.row)"
 | 
			
		||||
          >编辑</el-button>
 | 
			
		||||
          <el-button
 | 
			
		||||
            size="mini"
 | 
			
		||||
            type="text"
 | 
			
		||||
            icon="el-icon-delete"
 | 
			
		||||
            @click="handleDelete(scope.row)"
 | 
			
		||||
          >删除</el-button>
 | 
			
		||||
        </template>
 | 
			
		||||
      </el-table-column>
 | 
			
		||||
    </el-table>
 | 
			
		||||
 | 
			
		||||
    <pagination
 | 
			
		||||
| 
						 | 
				
			
			@ -83,13 +99,14 @@
 | 
			
		|||
                filterable
 | 
			
		||||
                style="width: 100%"
 | 
			
		||||
                :disabled="!form.deviceTypeId"
 | 
			
		||||
                :loading="modelLoading"
 | 
			
		||||
              >
 | 
			
		||||
                <el-option
 | 
			
		||||
                  v-for="item in deviceModelOptions"
 | 
			
		||||
                  :key="item.typeId"
 | 
			
		||||
                  :label="item.typeName"
 | 
			
		||||
                  :value="item.typeId"
 | 
			
		||||
                />
 | 
			
		||||
              <el-option
 | 
			
		||||
                v-for="item in deviceModelOptions"
 | 
			
		||||
                :key="item.typeId"
 | 
			
		||||
                :label="item.typeName"
 | 
			
		||||
                :value="item.typeId"
 | 
			
		||||
              />
 | 
			
		||||
              </el-select>
 | 
			
		||||
            </el-form-item>
 | 
			
		||||
          </el-col>
 | 
			
		||||
| 
						 | 
				
			
			@ -103,9 +120,9 @@
 | 
			
		|||
        </el-row>
 | 
			
		||||
        <el-row>
 | 
			
		||||
          <el-col :span="12">
 | 
			
		||||
            <el-form-item label="本次检验" prop="thisCheckDate">
 | 
			
		||||
            <el-form-item label="本次检验" prop="thisCheckTime">
 | 
			
		||||
              <el-date-picker
 | 
			
		||||
                v-model="form.thisCheckDate"
 | 
			
		||||
                v-model="form.thisCheckTime"
 | 
			
		||||
                type="date"
 | 
			
		||||
                placeholder="选择日期"
 | 
			
		||||
                value-format="yyyy-MM-dd"
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +135,7 @@
 | 
			
		|||
          <el-col :span="12">
 | 
			
		||||
            <el-form-item label="下次检验">
 | 
			
		||||
              <el-input
 | 
			
		||||
                v-model="form.nextCheckDate"
 | 
			
		||||
                v-model="form.nextCheckTime"
 | 
			
		||||
                readonly
 | 
			
		||||
                class="next-check-date"
 | 
			
		||||
              />
 | 
			
		||||
| 
						 | 
				
			
			@ -146,11 +163,11 @@
 | 
			
		|||
        </el-row>
 | 
			
		||||
        <el-row>
 | 
			
		||||
          <el-col :span="24">
 | 
			
		||||
            <el-form-item label="检验结论" prop="conclusion">
 | 
			
		||||
            <el-form-item label="检验结论" prop="result">
 | 
			
		||||
              <el-input
 | 
			
		||||
                type="textarea"
 | 
			
		||||
                :rows="3"
 | 
			
		||||
                v-model="form.conclusion"
 | 
			
		||||
                v-model="form.result"
 | 
			
		||||
                placeholder="请输入检验结论"
 | 
			
		||||
              />
 | 
			
		||||
            </el-form-item>
 | 
			
		||||
| 
						 | 
				
			
			@ -167,8 +184,8 @@
 | 
			
		|||
 | 
			
		||||
<script>
 | 
			
		||||
import {
 | 
			
		||||
  addWsMaInfoData,
 | 
			
		||||
  getDeviceType, getGadgetList
 | 
			
		||||
  addWsMaInfoData, delGadget,
 | 
			
		||||
  getDeviceType, getGadgetInfo, getGadgetList
 | 
			
		||||
} from '@/api/ma/device'
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
| 
						 | 
				
			
			@ -213,13 +230,14 @@ export default {
 | 
			
		|||
        deviceTypeId: null,
 | 
			
		||||
        deviceModelId: null,
 | 
			
		||||
        deviceCode: '',
 | 
			
		||||
        thisCheckDate: '',
 | 
			
		||||
        nextCheckDate: '',
 | 
			
		||||
        thisCheckTime: '',
 | 
			
		||||
        nextCheckTime: '',
 | 
			
		||||
        checkMan: '',
 | 
			
		||||
        repairMan: '',
 | 
			
		||||
        phone: '',
 | 
			
		||||
        conclusion: ''
 | 
			
		||||
        result: ''
 | 
			
		||||
      },
 | 
			
		||||
      modelLoading: false,
 | 
			
		||||
      // 表单校验
 | 
			
		||||
      rules: {
 | 
			
		||||
        deviceTypeId: [
 | 
			
		||||
| 
						 | 
				
			
			@ -231,7 +249,7 @@ export default {
 | 
			
		|||
        deviceCode: [
 | 
			
		||||
          { required: true, message: "设备编码不能为空", trigger: "blur" }
 | 
			
		||||
        ],
 | 
			
		||||
        thisCheckDate: [
 | 
			
		||||
        thisCheckTime: [
 | 
			
		||||
          { required: true, message: "本次检验日期不能为空", trigger: "change" }
 | 
			
		||||
        ],
 | 
			
		||||
        checkMan: [
 | 
			
		||||
| 
						 | 
				
			
			@ -243,7 +261,7 @@ export default {
 | 
			
		|||
        phone: [
 | 
			
		||||
          { required: true, message: "联系电话不能为空", trigger: "blur" }
 | 
			
		||||
        ],
 | 
			
		||||
        conclusion: [
 | 
			
		||||
        result: [
 | 
			
		||||
          { required: true, message: "检验结论不能为空", trigger: "blur" }
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
| 
						 | 
				
			
			@ -277,20 +295,29 @@ export default {
 | 
			
		|||
      })
 | 
			
		||||
    },
 | 
			
		||||
    /** 获取设备类型选项 */
 | 
			
		||||
    getDeviceTypeOptions() {
 | 
			
		||||
      // 这里替换为您的实际API调用
 | 
			
		||||
      getDeviceType({ level: 3, skipPermission: 1 }).then(response => {
 | 
			
		||||
        this.deviceTypeOptions = response.data;
 | 
			
		||||
      });
 | 
			
		||||
    async getDeviceTypeOptions() {
 | 
			
		||||
      try {
 | 
			
		||||
        const response = await getDeviceType({ level: 3, skipPermission: 1 });
 | 
			
		||||
        this.deviceTypeOptions = response.data || [];
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error('获取设备类型失败:', error);
 | 
			
		||||
        this.deviceTypeOptions = [];
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 设备类型变化时获取设备型号 */
 | 
			
		||||
    handleDeviceTypeChange(value) {
 | 
			
		||||
    async handleDeviceTypeChange(value) {
 | 
			
		||||
      this.form.deviceModelId = null;
 | 
			
		||||
      if (value) {
 | 
			
		||||
        // 这里替换为您的实际API调用
 | 
			
		||||
        getDeviceType({typeId:value}).then(response => {
 | 
			
		||||
          this.deviceModelOptions = response.data;
 | 
			
		||||
        });
 | 
			
		||||
        this.modelLoading = true;
 | 
			
		||||
        try {
 | 
			
		||||
          const response = await getDeviceType({ typeId: value });
 | 
			
		||||
          this.deviceModelOptions = response.data || [];
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
          console.error('获取设备型号失败:', error);
 | 
			
		||||
          this.deviceModelOptions = [];
 | 
			
		||||
        } finally {
 | 
			
		||||
          this.modelLoading = false;
 | 
			
		||||
        }
 | 
			
		||||
      } else {
 | 
			
		||||
        this.deviceModelOptions = [];
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			@ -308,9 +335,9 @@ export default {
 | 
			
		|||
        const month = (nextDate.getMonth() + 1).toString().padStart(2, '0');
 | 
			
		||||
        const day = nextDate.getDate().toString().padStart(2, '0');
 | 
			
		||||
 | 
			
		||||
        this.form.nextCheckDate = `${year}-${month}-${day}`;
 | 
			
		||||
        this.form.nextCheckTime = `${year}-${month}-${day}`;
 | 
			
		||||
      } else {
 | 
			
		||||
        this.form.nextCheckDate = '';
 | 
			
		||||
        this.form.nextCheckTime = '';
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -349,39 +376,79 @@ export default {
 | 
			
		|||
    handleAdd() {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      this.open = true;
 | 
			
		||||
      this.title = "添加设备检验信息";
 | 
			
		||||
      this.title = "添加小工具信息";
 | 
			
		||||
    },
 | 
			
		||||
    /** 编辑按钮操作 */
 | 
			
		||||
    handleEdit(row) {
 | 
			
		||||
    async handleEdit(row) {
 | 
			
		||||
      this.reset();
 | 
			
		||||
      // 这里替换为您的实际API调用
 | 
			
		||||
      getDeviceInfo(row.maId).then(response => {
 | 
			
		||||
        this.form = response.data;
 | 
			
		||||
      try {
 | 
			
		||||
        const response = await getGadgetInfo(row.id);
 | 
			
		||||
        this.form = { ...response.data };
 | 
			
		||||
        this.form.deviceCode = response.data.maCode;
 | 
			
		||||
 | 
			
		||||
        // 先设置设备类型ID
 | 
			
		||||
        this.form.deviceTypeId =response.data.deviceTypeId;
 | 
			
		||||
 | 
			
		||||
        // 加载设备类型选项(如果尚未加载)
 | 
			
		||||
        if (this.deviceTypeOptions.length === 0) {
 | 
			
		||||
          await this.getDeviceTypeOptions();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // 加载设备型号选项
 | 
			
		||||
        await this.handleDeviceTypeChange(this.form.deviceTypeId);
 | 
			
		||||
 | 
			
		||||
        // 设置设备型号ID - 确保选项已加载
 | 
			
		||||
        this.form.deviceModelId =response.data.deviceModelId;
 | 
			
		||||
 | 
			
		||||
        this.open = true;
 | 
			
		||||
        this.title = "修改设备检验信息";
 | 
			
		||||
      });
 | 
			
		||||
        this.title = "修改小工具信息";
 | 
			
		||||
      } catch (error) {
 | 
			
		||||
        console.error('获取设备信息失败:', error);
 | 
			
		||||
        this.$message.error('获取设备信息失败');
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    /** 删除按钮操作 */
 | 
			
		||||
    handleDelete(row) {
 | 
			
		||||
      this.$confirm('是否确认删除设备检验信息编号为"' + row.maId + '"的数据项?', "警告", {
 | 
			
		||||
      this.$confirm('是否确认删除设备编号为"' + row.maCode + '"的数据项?', "警告", {
 | 
			
		||||
        confirmButtonText: "确定",
 | 
			
		||||
        cancelButtonText: "取消",
 | 
			
		||||
        type: "warning"
 | 
			
		||||
      }).then(function() {
 | 
			
		||||
        // 这里替换为您的实际API调用
 | 
			
		||||
        return deleteDeviceInfo(row.maId);
 | 
			
		||||
      }).then(() => {
 | 
			
		||||
        this.getList();
 | 
			
		||||
        this.$message.success("删除成功");
 | 
			
		||||
      }).then(async () => {
 | 
			
		||||
        const loading = this.$loading({ text: '删除中...' })
 | 
			
		||||
        try {
 | 
			
		||||
          const res = await delGadget({ id: row.id})
 | 
			
		||||
          this.$message({
 | 
			
		||||
            type: 'success',
 | 
			
		||||
            message: '删除成功!'
 | 
			
		||||
          })
 | 
			
		||||
          this.getList()
 | 
			
		||||
        } catch (error) {
 | 
			
		||||
          console.log('删除失败', error)
 | 
			
		||||
        } finally {
 | 
			
		||||
          loading.close()
 | 
			
		||||
        }
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    /** 提交表单 */
 | 
			
		||||
    submitForm() {
 | 
			
		||||
      this.$refs["form"].validate(valid => {
 | 
			
		||||
        if (valid) {
 | 
			
		||||
          if (this.form.maId) {
 | 
			
		||||
          if (this.form.id) {
 | 
			
		||||
            const params = {
 | 
			
		||||
              id: this.form.id,
 | 
			
		||||
              maName: data.maName,
 | 
			
		||||
              maModel:data.maModel,
 | 
			
		||||
              modelId:this.form.deviceModelId,
 | 
			
		||||
              maCode:this.form.deviceCode,
 | 
			
		||||
              thisCheckTime:this.form.thisCheckTime,
 | 
			
		||||
              nextCheckTime:this.form.nextCheckTime,
 | 
			
		||||
              repairMan: this.form.repairMan,
 | 
			
		||||
              checkMan: this.form.checkMan,
 | 
			
		||||
              phone: this.form.phone,
 | 
			
		||||
              result:this.form.result,
 | 
			
		||||
            }
 | 
			
		||||
            // 这里替换为您的实际API调用
 | 
			
		||||
            updateDeviceInfo(this.form).then(response => {
 | 
			
		||||
            updateGadgetInfo(params).then(response => {
 | 
			
		||||
              this.$message.success("修改成功");
 | 
			
		||||
              this.open = false;
 | 
			
		||||
              this.getList();
 | 
			
		||||
| 
						 | 
				
			
			@ -404,12 +471,12 @@ export default {
 | 
			
		|||
              maModel:data.maModel,
 | 
			
		||||
              modelId:this.form.deviceModelId,
 | 
			
		||||
              maCode:this.form.deviceCode,
 | 
			
		||||
              thisCheckTime:this.form.thisCheckDate,
 | 
			
		||||
              nextCheckTime:this.form.nextCheckDate,
 | 
			
		||||
              thisCheckTime:this.form.thisCheckTime,
 | 
			
		||||
              nextCheckTime:this.form.nextCheckTime,
 | 
			
		||||
              repairMan: this.form.repairMan,
 | 
			
		||||
              checkMan: this.form.checkMan,
 | 
			
		||||
              phone: this.form.phone,
 | 
			
		||||
              result:this.form.conclusion,
 | 
			
		||||
              result:this.form.result,
 | 
			
		||||
            }
 | 
			
		||||
            // 这里替换为您的实际API调用
 | 
			
		||||
            addWsMaInfoData(params).then(response => {
 | 
			
		||||
| 
						 | 
				
			
			@ -433,8 +500,8 @@ export default {
 | 
			
		|||
        deviceTypeId: null,
 | 
			
		||||
        deviceModelId: null,
 | 
			
		||||
        deviceCode: '',
 | 
			
		||||
        thisCheckDate: '',
 | 
			
		||||
        nextCheckDate: '',
 | 
			
		||||
        thisCheckTime: '',
 | 
			
		||||
        nextCheckTime: '',
 | 
			
		||||
        checkMan: '',
 | 
			
		||||
        repairMan: '',
 | 
			
		||||
        phone: '',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue