zenglf
2023-09-18 92ff846fb659c62037a32b1d8c15eae9df9d9b54
src/views/eam/EquipmentCalibrationOrder.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,485 @@
<template>
  <a-card
    :bordered="false"
    title="设备检定工单"
  >
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form
        layout="inline"
        @keyup.enter.native="searchQuery"
      >
        <a-row :gutter="24">
          <a-col
            :md="6"
            :sm="8"
          >
            <a-form-item label="工单编码">
              <a-input
                placeholder="请输入工单编码"
                v-model="queryParam.num"
              ></a-input>
            </a-form-item>
          </a-col>
          <!-- <a-col
            :md="6"
            :sm="8"
          >
            <a-form-item label="点检方法名称">
              <j-input
                placeholder="请输入点检方法名称"
                v-model="queryParam.name"
              ></j-input>
            </a-form-item>
          </a-col> -->
          <a-col
            :md="6"
            :sm="8"
          >
            <span
              style="float: left;overflow: hidden;"
              class="table-page-search-submitButtons"
            >
              <a-button
                type="primary"
                @click="searchQuery"
                icon="search"
              >查询</a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
              >重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æŸ¥è¯¢åŒºåŸŸ-END -->
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator">
      <a-button
        @click="handleAdd"
        type="primary"
        icon="plus"
      >新增</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"
        :scroll="{ x: 'calc(2000px + 50%)', y: 900 }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        :rowSelection="rowSelection"
        :customRow="clickThenSelect"
      >
        <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->
        <span
          slot="action"
          slot-scope="text, record"
        >
          <a-popconfirm
            title="确定下发工单吗?"
            @confirm="() => handleOrderIssue(record)"
          >
            <a v-if="record.status === '1'">下发</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status === '1'"
            type="vertical"
          />
          <a
            v-if="record.status === '1'"
            @click="handleEdit(record)"
          >编辑</a>
          <a-divider
            v-if="record.status === '1'"
            type="vertical"
          />
          <a
            v-if="record.status === '2' "
            @click="handleOrderExe(record)"
          >执行</a>
          <a-divider
            v-if="record.status === '2'"
            type="vertical"
          />
          <a
            v-if="record.status === '4'"
            @click="handleOrderExe(record)"
          >查看</a>
          <a-divider
            v-if="record.status === '4'"
            type="vertical"
          />
          <a-popconfirm
            title="确定撤回工单吗?"
            @confirm="() => handleOrderReset(record,'1')"
          >
            <a v-if="record.status === '2'">撤回</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status === '2'"
            type="vertical"
          />
          <a-popconfirm
            title="确定撤回工单吗?"
            @confirm="() => handleOrderReset(record,'2')"
          >
            <a v-if="record.status === '4'">撤回</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status === '4'"
            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>
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                >
                  <a v-if="record.status === '1'">删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
        <span
          slot="num"
          slot-scope="text, record"
        >
          <a
            v-if="record.status === '3' || record.status === '2' "
            class="lot"
            @click="handleOrderExe(record)"
          >{{record.num}}</a>
          <span v-else>{{record.num}}</span>
        </span>
      </a-table>
      <a-tabs
        type="card"
        defaultActiveKey="1"
      >
        <a-tab-pane
          key="1"
          forceRender
        >
          <span slot="tab">
            <a-badge>精度参数&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
          </span>
          <div
            class="table-operator"
            style="margin:10px"
          >
            <equipment-precision-parameters-list ref="PrecisionParametersList"></equipment-precision-parameters-list>
          </div>
        </a-tab-pane>
        <a-tab-pane
          key="2"
          forceRender
        >
          <span slot="tab">
            <a-badge>检定报告&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a-badge>
          </span>
          <div
            class="table-operator"
            style="margin:10px"
          >
            <equipment-calibration-order-report-list ref="EquipmentCalibrationOrderReportList"></equipment-calibration-order-report-list>
          </div>
        </a-tab-pane>
      </a-tabs>
    </div>
    <equipment-calibration-order-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></equipment-calibration-order-modal>
    <equipment-calibration-order-exe-drawer
      ref="EquipmentCalibrationOrderExeDrawer"
      @ok="modalFormOk"
    ></equipment-calibration-order-exe-drawer>
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import EquipmentCalibrationOrderModal from './modules/equipmentCalibrationOrder/EquipmentCalibrationOrderModal'
import EquipmentCalibrationOrderExeDrawer from './modules/equipmentCalibrationOrder/EquipmentCalibrationOrderExeDrawer'
import { getAction, postAction, requestPut } from '@/api/manage'
import EquipmentPrecisionParametersList from './modules/equipmentCalibrationOrder/EquipmentPrecisionParametersList'
import EquipmentCalibrationOrderReportList from './modules/equipmentCalibrationOrder/EquipmentCalibrationOrderReportList'
export default {
  name: 'EquipmentCalibrationOrder',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    EquipmentCalibrationOrderModal,
    EquipmentCalibrationOrderExeDrawer,
    EquipmentPrecisionParametersList,
    EquipmentCalibrationOrderReportList,
  },
  data() {
    return {
      description: '设备检定工单',
      /* åˆ†é¡µå‚æ•° */
      ipagination: {
        current: 1,
        pageSize: 5,
        pageSizeOptions: ['5', '10', '50'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " å…±" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      // è¡¨å¤´
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '状态',
          align: "center",
          dataIndex: 'status_dictText'
        },
        {
          title: '工单号',
          align: "center",
          dataIndex: 'num',
          // scopedSlots: { customRender: 'num' }
        },
        {
          title: '检定方式',
          align: "center",
          dataIndex: 'calibrationType_dictText',
        },
        {
          title: '设备编码',
          align: "center",
          dataIndex: 'equipmentNum',
        },
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'equipmentName',
        },
        {
          title: '型号',
          align: "center",
          dataIndex: 'equipmentModel',
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'equipmentSpecification',
        },
        {
          title: '判定依据',
          align: "center",
          dataIndex: 'managementMode_dictText',
        },
        {
          title: '判定结果',
          align: "center",
          dataIndex: 'calibrationResult'
        },
        {
          title: '创建人',
          align: "center",
          dataIndex: 'createBy'
        },
        {
          title: '创建日期',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '检定人',
          align: "center",
          dataIndex: 'calibrationUserId_dictText'
        },
        {
          title: '完成时间',
          align: "center",
          dataIndex: 'calibrationTime'
        },
        {
          title: '下发时间',
          align: "center",
          dataIndex: 'issueTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 300,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/eam/calibrationOrder/listNew",
        delete: "/eam/calibrationOrder/delete",
        edit: "/eam/calibrationOrder/editStatus",
      },
    }
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    rowSelection() {
      return {
        type: 'checkbox',
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys;
          this.onSelectChange(selectedRowKeys, selectedRows);
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.distable
          },
        }),
        selectedRowKeys: this.selectedRowKeys,
      };
    },
  },
  methods: {
    clickThenSelect(record) {
      return {
        on: {
          click: () => {
            this.onSelectChange(record.id.split(","), [record]);
          }
        }
      }
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      if (selectedRowKeys.length == 1) {
        this.$refs.EquipmentCalibrationOrderReportList.calibrationOrderId = selectedRowKeys[0]
        this.$refs.PrecisionParametersList.calibrationOrderId = selectedRowKeys[0]
      } else {
        this.$refs.PrecisionParametersList.calibrationOrderId = '-1'
        this.$refs.EquipmentCalibrationOrderReportList.calibrationOrderId = '-1'
      }
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    handleOrderExe(record) {
      this.$refs.EquipmentCalibrationOrderExeDrawer.visible = true
      this.$refs.EquipmentCalibrationOrderExeDrawer.title = '检定工单执行'
      this.$refs.EquipmentCalibrationOrderExeDrawer.handleShow(record)
      if (record.status === '4') {
        this.$refs.EquipmentCalibrationOrderExeDrawer.buttonDistable = true//保存、暂存、报工
        this.$refs.EquipmentCalibrationOrderExeDrawer.revocationDistable = true//撤销按钮
        this.$refs.EquipmentCalibrationOrderExeDrawer.SWbuttonDistable = true//提交按钮
      } else if (record.status === '2') {
        this.$refs.EquipmentCalibrationOrderExeDrawer.buttonDistable = false//保存、暂存、报工
        this.$refs.EquipmentCalibrationOrderExeDrawer.revocationDistable = true//撤销按钮
        this.$refs.EquipmentCalibrationOrderExeDrawer.SWbuttonDistable = false//提交按钮
      }
    },
    handleOrderIssue(record) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: '2' }).then((res) => {
        if (res.success) {
          that.$message.success("工单下发成功!")
          that.loadData()
        } else {
          that.$message.warning("工单下发失败!")
        }
      })
    },
    //撤回
    handleOrderReset(record, status) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: status }).then((res) => {
        if (res.success) {
          that.$message.success("工单撤回成功!")
          that.loadData()
        } else {
          that.$message.warning("工单撤回失败!")
        }
      })
    },
    searchQuery() {
      this.$refs.PrecisionParametersList.calibrationOrderId = '-1'
      this.$refs.EquipmentCalibrationOrderReportList.calibrationOrderId = '-1'
      this.loadData(1);
    },
    searchReset() {
      this.queryParam = {};
      this.selectedRowKeys = []
      this.selectionRows = []
      this.$refs.PrecisionParametersList.calibrationOrderId = '-1'
      this.$refs.EquipmentCalibrationOrderReportList.calibrationOrderId = '-1'
      this.loadData(1);
    },
    modalFormOk() {
      // æ–°å¢ž/修改 æˆåŠŸæ—¶ï¼Œé‡è½½åˆ—è¡¨
      this.loadData()
      //清空列表选中
      this.onClearSelected()
      this.$refs.PrecisionParametersList.calibrationOrderId = '-1'
      this.$refs.EquipmentCalibrationOrderReportList.calibrationOrderId = '-1'
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>