zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/eam/RepairOrderFinishedReport.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,784 @@
<template>
  <a-card
    title="修后汇报"
    :bordered="false"
  >
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <div class="table-page-search-wrapper">
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
          <a-col
            :xl="6"
            :lg="7"
            :md="8"
            :sm="24"
          >
            <a-form-item label="工单状态">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择工单状态"
                :triggerChange="true"
                dictCode="audit_status"
                v-model="queryParam.auditStatus"
              />
            </a-form-item>
          </a-col>
          <a-col
            :xl="6"
            :lg="7"
            :md="8"
            :sm="24"
          >
            <a-form-item label="单据号">
              <a-input
                placeholder="请输入单据号"
                v-model="queryParam.num"
              ></a-input>
            </a-form-item>
          </a-col>
          <a-col
            :xl="6"
            :lg="7"
            :md="8"
            :sm="24"
          >
            <a-form-item label="设备编码">
              <a-input
                placeholder="请输入设备编码"
                v-model="queryParam.equipmentNum"
              ></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col
            :md="4"
            :sm="8"
          >
            <a-form-item label="设备名称">
              <a-input
                placeholder="请输入设备名称"
                v-model="queryParam.equipmentName"
              ></a-input>
            </a-form-item>
          </a-col> -->
          <a-col
            :md="4"
            :sm="8"
          >
            <a-button
              type="primary"
              @click="searchQuery"
              icon="search"
              style="margin-right: 5px"
            >查询</a-button>
            <a-button
              @click="searchReset"
              icon="reload"
            >重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator">
      <!-- <a-dropdown>
        <a-menu slot="overlay">
          <a-menu-item
            key="1"
            @click="handleAddPre(true)"
          ><a-icon type="smile" />自建</a-menu-item>
          <a-menu-item
            key="2"
            @click="handleAddPre(false)"
          ><a-icon type="copy" />参照保修故障单</a-menu-item>
        </a-menu>
        <a-button
          type="primary"
          icon="plus"
        >新增</a-button>
      </a-dropdown>
      <a-button
        type="primary"
        icon="plus"
        @click="handleDispatch()"
        :disabled="selectionRows.length==0"
        v-if="false"
      >派工</a-button> -->
      <a-button
        type="primary"
        icon="plus"
        @click="handleAddPre(true)"
      >新增</a-button>
    </div>
    <!-- table区域-begin -->
    <div>
      <!-- <div
        class="ant-alert ant-alert-info"
        style="margin-bottom: 16px;"
      >
        <i class="anticon anticon-info-circle ant-alert-icon"></i> å·²é€‰æ‹© <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a
          style="margin-left: 24px"
          @click="onClearSelected"
        >清空</a>
      </div> -->
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{ x: 'calc(1900px + 50%)', y: 900 }"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
        :customRow="clickThenSelect"
      >
        <!-- :rowSelection="rowSelection" -->
        <template
          slot="htmlSlot"
          slot-scope="text"
        >
          <div v-html="text"></div>
        </template>
        <template
          slot="imgSlot"
          slot-scope="text,record"
        >
          <span
            v-if="!text"
            style="font-size: 12px;font-style: italic;"
          >无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"
          />
        </template>
        <template
          slot="fileSlot"
          slot-scope="text"
        >
          <span
            v-if="!text"
            style="font-size: 12px;font-style: italic;"
          >无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)"
          >
            ä¸‹è½½
          </a-button>
        </template>
        <span
          slot="action"
          slot-scope="text, record"
        >
          <a-popconfirm
            v-if="record.auditStatus == 'notSubmitted'"
            title="确认提交吗?"
            @confirm="() =>handleCommit(record, 'commit')"
          >
            <a>提交</a>
          </a-popconfirm>
          <a-popconfirm
            v-if="record.auditStatus == 'pendingApproval'"
            title="确认撤回吗?"
            @confirm="() =>handleCommit(record, 'back')"
          >
            <a>撤回</a>
          </a-popconfirm>
          <a-divider
            v-if="record.auditStatus == 'notSubmitted' || record.auditStatus == 'pendingApproval'"
            type="vertical"
          />
          <a
            v-if="record.auditStatus == 'notSubmitted' "
            @click="handleEdit(record)"
          >编辑</a>
          <a
            v-if="record.auditStatus == 'pendingApproval'"
            @click="handleApprove(record)"
          >审批</a>
          <a-divider
            v-if="record.auditStatus == 'notSubmitted' || record.auditStatus == 'pendingApproval'"
            type="vertical"
          />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item v-if="record.auditStatus == 'notSubmitted'">
                <a-popconfirm
                  v-if="record.auditStatus == 'notSubmitted'"
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                >
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
              <!-- <a-menu-item v-if="record.auditStatus == '3' || record.auditStatus == '4'">
                <a-popconfirm
                  v-if="record.auditStatus == '3' || record.auditStatus == '4'"
                  title="确认撤销吗?"
                  @confirm="() =>handleFinish(record, 'revoke')"
                >
                  <a>撤销</a>
                </a-popconfirm>
              </a-menu-item> -->
            </a-menu>
          </a-dropdown>
        </span>
        <!-- <span
          slot="action"
          slot-scope="text, record"
        >
          <span
            v-if="record.auditStatus=='7'"
            style="font-size: 12px;font-style: italic;"
          >已确认</span>
          <a-popconfirm
            title="确定提交吗?"
            @confirm="() => handleReport(record)"
          >
            <a v-if="record.auditStatus=='0'">提交</a>
          </a-popconfirm>
          <a-divider
            type="vertical"
            v-if="record.auditStatus=='0'"
          />
          <a-popconfirm
            title="确定撤回吗?"
            @confirm="() => handleWithdraw(record)"
          >
            <a v-if="record.auditStatus=='4'">撤回</a>
          </a-popconfirm>
          <a-divider
            type="vertical"
            v-if="record.auditStatus=='4'"
          />
          <a-popconfirm
            title="确认吗?"
            @confirm="() => handleConfirm(record)"
          >
            <a v-if="record.auditStatus=='4'">确认</a>
          </a-popconfirm>
          <a-divider
            type="vertical"
            v-if="record.auditStatus=='1'"
          />
          <a
            @click="handleEditPre(record)"
            v-if="record.auditStatus=='0'"
          >编辑</a>
          <a-divider
            type="vertical"
            v-if="record.auditStatus=='0'"
          />
          <a-dropdown v-if="record.auditStatus=='0'">
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                >
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span> -->
      </a-table>
    </div>
    <a-tabs
      type="card"
      defaultActiveKey="1"
    >
      <a-tab-pane
        tab="故障描述"
        key="1"
      >
        <div
          class="table-operator"
          style="margin-top: 0px"
        >
          <FaultDescriptionList ref="FaultDescriptionList" />
        </div>
      </a-tab-pane>
      <a-tab-pane
        tab="实际物料"
        key="2"
        forceRender
      >
        <RepairOrderActualMaterialList :mainId="repairOrderActualMaterialMainId" />
      </a-tab-pane>
      <a-tab-pane
        tab="实际工时"
        key="3"
        forceRender
      >
        <RepairOrderActualWorkHoursList :mainId="repairOrderActualWorkHoursMainId" />
      </a-tab-pane>
      <a-tab-pane
        tab="故障分析"
        key="4"
        forceRender
      >
        <RepairOrderFaultAnalysisList :mainId="repairOrderFaultAnalysisMainId" />
      </a-tab-pane>
    </a-tabs>
    <repairOrder-modal
      ref="modalForm"
      @ok="modalFormOk"
      :isSelfCreate="isSelfCreate"
    ></repairOrder-modal>
    <approvel-modal
      ref='approvalModalForm'
      @ok='approvalModalFormOk'
      @cancel='approvalModalFormOk'
      @loadData = "loadData"
    ></approvel-modal>
  </a-card>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@/api/manage'
import '@/assets/less/TableExpand.less'
import { putAction } from '../../api/manage'
import RepairOrderModal from './modules/repairorderfinished/RepairOrderFinishedReportModel'
import RepairOrderActualMaterialList from './repairOrderFinishedReport/RepairOrderActualMaterialReport.vue'
import RepairOrderActualWorkHoursList from './repairOrderFinishedReport/RepairOrderActualHoursReport'
import RepairOrderFaultAnalysisList from './repairOrderFinishedReport/RepairOrderFaultAnalysisReport.vue'
import RepairOrderDetailList from './repairOrderFinishedReport/RepairOrderDetailReport.vue'
import FaultDescriptionList from './FaultDescriptionList'
import ApprovelModal from './repairOrderFinishedReport/modules/ApprovelModal'
export default {
  name: "RepairOrderFinishedReport",
  mixins: [JeecgListMixin],
  components: {
    RepairOrderDetailList,
    RepairOrderFaultAnalysisList,
    RepairOrderActualMaterialList,
    RepairOrderActualWorkHoursList,
    RepairOrderModal,
    FaultDescriptionList,
    ApprovelModal
  },
  data() {
    return {
      description: '修后汇报页面',
      // è¡¨å¤´
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'auditStatusName'
        },
        {
          /*单据号*/
          title: '单据号',
          align: "center",
          dataIndex: 'num'
        },
        {
          title: '设备编码',
          align: "center",
          dataIndex: 'equipmentNum'
        },
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'equipmentName'
        },
        {
          title: '设备型号',
          align: "center",
          dataIndex: 'equipmentModel'
        },
        {
          /*调整字段*/
          title: '使用部门',
          align: "center",
          dataIndex: 'departName'
        },
        {
          title: '工时定额',
          align: "center",
          dataIndex: 'workingHourQuota'
        },
        {
          title: '故障描述',
          align: "center",
          dataIndex: 'faultDescription'
        },
        {
          title: '故障时间',
          align: "center",
          width: 150,
          dataIndex: 'faultTime'
        },
        /* {
           title: '故障照片',
           align: "center",
           dataIndex: 'photo',
           scopedSlots: { customRender: 'imgSlot' }
         },*/
        // {
        //   title: '报修人',
        //   align: "center",
        //   dataIndex: 'reportUserName'
        // },
        /*  {
            title: '是否停机',
            align: "center",
            dataIndex: 'isStop_dictText'
          },*/
        {
          title: '维保方式',
          align: "center",
          dataIndex: 'maintenanceMethodName'
        },
        {
          /*新增字段需要修改*/
          title: '责任班组',
          align: "center",
          width: 150,
          dataIndex: 'teamName'
        },
        {
          /*新增字段需要修改*/
          title: '责任人',
          align: "center",
          dataIndex: 'responsibilityName'
        },
        {
          /*新增字段需要修改*/
          title: '实际工时',
          align: "center",
          dataIndex: 'actualHour'
        },
        {
          /*新增字段需要修改*/
          title: '实际开始时间',
          align: "center",
          width: 150,
          dataIndex: 'actualStartTime'
        },
        {
          /*新增字段需要修改*/
          title: '实际完成时间',
          align: "center",
          width: 150,
          dataIndex: 'actualEndTime'
        },
        {
          /*新增字段需要修改*/
          title: '委外单位',
          align: "center",
          dataIndex: 'outsourcingUnitName'
        },
        {
          title: '创建人',
          align: "center",
          dataIndex: 'createBy'
        },
        {
          title: '创建时间',
          align: "center",
          width: 150,
          dataIndex: 'createTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 200,
          scopedSlots: { customRender: 'action' },
        }
      ],
      url: {
        list: "/eam/reportAfterRepair/getReportAfterRepairList",
        edit: "/eam/reportAfterRepair/edit",
        delete: "/eam/reportAfterRepair/delete",
        deleteBatch: "/eam/reportAfterRepair/deleteBatch",
        exportXlsUrl: "/eam/reportAfterRepair/exportXls",
        importExcelUrl: "/eam/reportAfterRepair/importExcel",
        orderReport: "eam/repairOrder/report",
        orderWithdraw: "eam/repairOrder/withdraw",
        orderDispatch: "eam/repairOrder/dispatch",
        orderReceive: "eam/repairOrder/receive",
        orderStart: "eam/repairOrder/start",
        orderConfirm: "eam/repairOrder/confirm"
      },
      dictOptions: {
      },
      /* åˆ†é¡µå‚æ•° */
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '50'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " å…±" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      selectedMainId: '',
      // superFieldList: [],
      repairOrderDetailMainId: '',
      repairOrderRiskPreventionMainId: '',
      repairOrderFaultAnalysisMainId: '',
      repairOrderFaultAnalysis: {},
      repairOrderPlanMaterialMainId: '',
      repairOrderActualMaterialMainId: '',
      repairOrderActualWorkHoursMainId: '',
      equipmentDocumentMainId: '',
      isSelfCreate: true,
      excuteRepairOrder: {},
      assignTaskList: [],
      sonsAddStatus: false,
    }
  },
  // created() {
  //   this.getSuperFieldList();
  // },
  watch: {
    selectionRows() {
      this.$bus.$emit('repairOrderSelectionRows', this.selectionRows);
    },
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    rowSelection() {
      return {
        type: 'checkbox',
        onChange: (selectedRowKeys, selectedRows) => {
          this.onSelectChange(selectedRowKeys, selectedRows);
        },
        getCheckboxProps: record => ({
          props: {
          },
        }),
        selectedRowKeys: this.selectedRowKeys,
      };
    },
  },
  methods: {
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange(record.id.split(","), [record]);
          }
        }
      }
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
      this.selectedMainId = ''
      this.repairOrderDetailMainId = ''
      this.repairOrderRiskPreventionMainId = ''
      this.repairOrderFaultAnalysisMainId = ''
      this.repairOrderPlanMaterialMainId = ''
      this.repairOrderActualMaterialMainId = ''
      this.repairOrderActualWorkHoursMainId = ''
      this.equipmentDocumentMainId = ''
      this.repairOrderFaultAnalysis = {}
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      if (selectedRowKeys.length == 1) {
        this.selectedMainId = selectedRowKeys[0]
        this.repairOrderDetailMainId = selectionRows[0]['id']
        this.repairOrderRiskPreventionMainId = selectionRows[0]['id']
        this.repairOrderFaultAnalysisMainId = selectionRows[0]['id']
        this.repairOrderFaultAnalysis = selectionRows[0]
        console.log(this.repairOrderActualMaterial)
        this.repairOrderPlanMaterialMainId = selectionRows[0]['id']
        this.repairOrderActualMaterialMainId = selectionRows[0]['id']
        this.repairOrderActualWorkHoursMainId = selectionRows[0]['id']
        this.equipmentDocumentMainId = selectionRows[0]['id']
        this.sonsAddStatus = (selectionRows[0]['status'] == '0' || selectionRows[0]['status'] == '1' || selectionRows[0]['status'] == '2')
        this.$refs.FaultDescriptionList.faultId = selectedRowKeys[0]
      } else {
        this.$refs.FaultDescriptionList.faultId = '-1'
        this.selectedMainId = ''
        this.repairOrderDetailMainId = ''
        this.repairOrderRiskPreventionMainId = ''
        this.repairOrderFaultAnalysisMainId = ''
        this.repairOrderPlanMaterialMainId = ''
        this.repairOrderActualMaterialMainId = ''
        this.repairOrderActualWorkHoursMainId = ''
        this.equipmentDocumentMainId = ''
      }
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
      this.assignTaskList = [];
      for (var i = 0; i < selectionRows.length; i++) {
        if (selectionRows[i].status == '1') {
          this.assignTaskList.push(selectionRows[i]);
        }
      }
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      //加载数据 è‹¥ä¼ å…¥å‚æ•°1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      this.onClearSelected()
      //this.queryParam.repairOrderType = 1;
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records;
          this.ipagination.total = res.result.total;
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false;
        this.$refs.FaultDescriptionList.faultId = '-1'
      })
    },
    handleAddPre(isSelfCreate) {
      this.isSelfCreate = isSelfCreate;
      this.handleAdd();
    },
    handleEditPre(record) {
      console.log(record);
      if (record.reportRepairId == null && record.reportRepairId == undefined && record.reportRepairId == '') {
        this.isSelfCreate = true;
      }
      else {
        this.isSelfCreate = false;
      }
      this.handleEdit(record);
    },
    //工单流程操作
    handleCommit(record, type) {
      type == 'commit' ? record.auditStatus = 'pendingApproval' : record.auditStatus = 'notSubmitted'
      putAction(this.url.edit, record).then(res => {
        if (res.success) {
          if (type === 'commit') {
            this.$message.success("提交成功!");
          } else {
            this.$message.success("撤回成功!");
          }
          this.loadData();
        } else {
          this.$message.warning(res.message);
        }
      })
    },
    handleApprove: function (record) {
      let edit
      edit = this.url.edit
      this.$refs.approvalModalForm.showModals(record, edit, 'Approved', 'Rejected')
      this.$refs.approvalModalForm.title = '审批'
      this.$refs.approvalModalForm.disableSubmit = false
    },
    handleDispatch() {
      if (this.assignTaskList.length == 0) {
        this.$message.warn('所选工单无需派工');
      } else {
        this.$refs.RepairOrderAssignModal.visible = true
        this.$refs.RepairOrderAssignModal.title = '维修工单派工'
        this.$refs.RepairOrderAssignModal.selectionRows
        this.$refs.RepairOrderAssignModal.handleShow()
      }
    },
    handleWithdraw(record) {
      putAction(this.url.orderWithdraw, record).then(res => {
        if (res.result) {
          this.$message.success('撤销成功');
          this.loadData();
        } else {
          this.$message.error('撤销出现异常')
        }
      })
    },
    handleConfirm(record) {
      putAction(this.url.orderConfirm, record).then(res => {
        if (res.result) {
          this.$message.success('确认成功');
          this.loadData();
        } else {
          this.$message.error('确认出现异常')
        }
      })
    },
    searchQuery() {
      this.loadData(1)
      this.selectedRowKeys = []
      this.selectionRows = []
      this.onClearSelected()
      this.$refs.FaultDescriptionList.faultId = '-1'
    },
    searchReset() {
      this.queryParam = {}
      this.loadData(1)
      this.onClearSelected()
      this.$refs.FaultDescriptionList.faultId = '-1'
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>