Просмотр исходного кода

feat(repair): 实现维修工单委外功能

- 新增委外表单组件 BaseOutForm.vue,用于创建委外单
- 新增委外详情组件 DetailRepairOut.vue,展示委外单详细信息
- 在工单详情页面 DetailRepair.vue 中集成委外记录展示和委外操作按钮
- 添加委外相关API接口,包括创建、完成、查询等功能
- 修改工单状态逻辑,调整委外触发条件
- 新增委外记录表格展示,包含委外单号、类别、状态等信息
- 实现委外单完成功能,支持上传完成图片和附件
- 重构表单字段映射,统一使用repairId作为关联字段
dazhaxie 1 неделя назад
Родитель
Сommit
7aced8583c

+ 1 - 1
public/hitch-screen/index.html

@@ -20,7 +20,7 @@
   <div class="title-name">设备运行状态一览图</div>
   <div class="title-icon">
     <label class="legend-item legend-normal"><input type="checkbox" id="filterNormal" checked> 正常设备</label>
-    <label class="legend-item legend-yellow"><input type="checkbox" id="filterPlanned" checked> 计划性维修设备</label>
+    <label class="legend-item legend-yellow"><input type="checkbox" id="filterPlanned" checked> 问题设备</label>
 <!--    <label class="legend-item legend-red"><input type="checkbox" id="filterUnplanned" checked> 非计划性维修设备</label>-->
   </div>
   <div id="echart" class="echart"></div>

+ 71 - 0
src/api/repair/entrust.js

@@ -0,0 +1,71 @@
+import { axios } from '@/utils/request'
+import { stringify } from 'qs'
+
+/**
+ * 创建委外单
+ */
+export function createRepairEntrust (parameter) {
+  return axios({
+    url: '/repair/entrusts',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
+
+/**
+ * 完成委外单
+ */
+export function finishRepairEntrust (id, parameter) {
+  return axios({
+    url: '/repair/entrusts/finish/' + id,
+    method: 'PUT',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
+
+/**
+ * 获取委外单详情
+ */
+export function fetchRepairEntrust (id) {
+  return axios({
+    url: '/repair/entrusts/' + id,
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * 委外单分页列表
+ */
+export function getRepairEntrustPage (parameter) {
+  return axios({
+    url: '/repair/entrusts/page?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * 根据工单ID查询委外单列表
+ */
+export function getRepairEntrustByRepairId (repairId) {
+  return axios({
+    url: '/repair/entrusts/by-repair/' + repairId,
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}

+ 7 - 0
src/views/repair/application-form/RepairForm.vue

@@ -392,6 +392,13 @@ export default {
     handleView (record) {
       fetchRepairApplicationForm({ id: record.id }).then(res => {
         this.visible = false
+        // 收起可能残留的详情卡片,避免新旧详情(委外详情)同时显示
+        if (this.$refs.detailModal) {
+          this.$refs.detailModal.visible = false
+        }
+        if (this.$refs.detailOutModal) {
+          this.$refs.detailOutModal.visible = false
+        }
         const type = res.data.type
         const modal = type === 2 ? this.$refs.detailOutModal : this.$refs.detailModal
         modal.base(res.data)

+ 57 - 201
src/views/repair/application-form/RepairOut.vue

@@ -6,10 +6,18 @@
           <a-row :gutter="48">
             <a-col :md="8" :sm="24">
               <a-form-item label="关键字">
-                <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称"/>
+                <a-input v-model="queryParam.keyword" placeholder="委外单号/工单号/设备/人员"/>
               </a-form-item>
             </a-col>
-            <a-col :md="8 || 24" :sm="24">
+            <a-col :md="8" :sm="24">
+              <a-form-item label="状态">
+                <a-select v-model="queryParam.status" placeholder="全部" allowClear>
+                  <a-select-option :value="1">委外维修中</a-select-option>
+                  <a-select-option :value="2">已完成</a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :md="8" :sm="24">
               <span class="table-page-search-submitButtons">
                 <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
                 <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
@@ -19,85 +27,56 @@
         </a-form>
       </div>
 
-      <div class="table-operator">
-        <!--        <a-button v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="$refs.baseModal.base({},{filter: -1})">新增</a-button>-->
-        <!--       <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-add')" type="primary" icon="plus" @click="$refs.baseOutModal.base()">新增</a-button>-->
-        <a-button style="margin-left: 8px" v-if="$auth('repair-application-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
-        <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('repair-application-forms-del')">
-          <a-menu slot="overlay">
-            <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
-              <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
-            </a-popconfirm>
-          </a-menu>
-          <a-button style="margin-left: 8px">
-            批量操作 <a-icon type="down" />
-          </a-button>
-        </a-dropdown>
-      </div>
-
       <s-table
         ref="table"
         size="default"
         rowKey="id"
         :columns="columns"
         :data="loadData"
-        :alert="options.alert"
-        :rowSelection="options.rowSelection"
         showPagination="auto"
       >
         <span slot="action" slot-scope="record">
           <template>
             <a @click="handleView(record)">查看</a>
-
-            <operation-button
-              v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-edit')"
-              @click="handleEdit(record)" >修改</operation-button>
-            <operation-button
-              v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-del')"
-              :type="2"
-              title="是否要删除该条数据?"
-              @confirm="batchDelete(record.id)">删除</operation-button>
-            <!--<operation-button
-              v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === record.status && $auth('repair-application-forms-dispatch')"
-              @click="handleDispatching(record)" >派工</operation-button>-->
+            <a-divider type="vertical" v-if="record.status === 1"/>
+            <a v-if="record.status === 1" @click="handleFinish(record)">完成</a>
           </template>
         </span>
         <span slot="status" slot-scope="text">
-          <badge :text="BaseTool.Object.getField(statusMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[text]"/>
+          <badge :text="entrustStatusMap[text]" :status="text === 1 ? 'processing' : 'success'"/>
         </span>
-        <span slot="level" slot-scope="text">
-          <badge :text="BaseTool.Object.getField(levelMap,text)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_LEVEL[text]"/>
+        <span slot="outType" slot-scope="text">
+          {{ outTypeMap[text] || '' }}
         </span>
       </s-table>
     </div>
-    <base-form ref="baseOutModal" @ok="handleOk"/>
     <detail-out ref="detailOutModal" @ok="handleOk"/>
+    <finish-out-form ref="finishForm" @ok="handleOk"/>
   </a-card>
 </template>
 
 <script>
-import { STable, Ellipsis } from '@/components'
-import BaseForm from './modules/BaseOutForm'
+import { STable } from '@/components'
 import DetailOut from './modules/DetailRepairOut'
-import { getRepairApplicationFormPage, deleteRepairApplicationForms, fetchRepairApplicationForm, exportRepairApplicationForm } from '@/api/repair/application-form'
+import FinishOutForm from './modules/FinishOutForm'
+import { getRepairEntrustPage } from '@/api/repair/entrust'
 
 export default {
   name: 'RepairOut',
   components: {
     STable,
-    Ellipsis,
-    BaseForm,
-    DetailOut
+    DetailOut,
+    FinishOutForm
   },
   data () {
     return {
-      // 查询参数
-      queryParam: {
-        filter: 0,
-        searchType: 2
-      },
+      queryParam: {},
       visible: true,
-      // 表头
+      outTypeMap: {},
+      entrustStatusMap: {
+        1: '委外维修中',
+        2: '已完成'
+      },
       columns: [
         {
           title: '序号',
@@ -110,9 +89,13 @@ export default {
         {
           title: '委外单号',
           checked: true,
-          dataIndex: 'outNo'
+          dataIndex: 'entrustNo'
+        },
+        {
+          title: '工单号',
+          checked: true,
+          dataIndex: 'repairNo'
         },
-
         {
           title: '设备编号',
           checked: true,
@@ -121,203 +104,76 @@ export default {
         {
           title: '设备名称',
           checked: true,
-          dataIndex: 'sbId',
-          customRender: (text, record, index) => {
-            return record.sbName
-          }
+          dataIndex: 'sbName'
         },
-        // {
-        //   title: '报修人',
-        //   checked: true,
-        //   dataIndex: 'actualUser'
-        // },
         {
-          title: '维修人',
+          title: '委外申请人',
           checked: true,
-          dataIndex: 'repairUserName'
+          dataIndex: 'entrustUserName'
         },
-      /*  {
-          title: '报修来源',
-          // checked: true,
-          dataIndex: 'source',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Object.getField(this.sourceMap, text)
-          }
-        },*/
         {
-          title: '工单类型',
+          title: '委外维修人',
           checked: true,
-          width: '100px',
-          dataIndex: 'category',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Object.getField(this.planFlagMap, text)
-          }
+          dataIndex: 'repairUserName'
         },
         {
-          title: '报修时间',
+          title: '委外类别',
           checked: true,
-          dataIndex: 'applyTime'
+          dataIndex: 'outType',
+          scopedSlots: { customRender: 'outType' }
         },
-        // {
-        //   title: '紧急等级',
-        //   checked: true,
-        //   dataIndex: 'level',
-        //   customRender: (text, record, index) => {
-        //     return this.BaseTool.Object.getField(this.levelMap, text)
-        //   }
-        // },
-        // {
-        //   title: '计划性维修',
-        //   checked: true,
-        //   dataIndex: 'needStop',
-        //   customRender: (text, record, index) => {
-        //     return this.BaseTool.Object.getField(this.needStopMap,text)
-        //   }
-        // },
         {
-          title: '报修状态',
+          title: '状态',
           checked: true,
           dataIndex: 'status',
           scopedSlots: { customRender: 'status' }
         },
-
         {
-          title: '创建日期',
+          title: '创建时间',
+          checked: true,
           dataIndex: 'createdTime'
         },
         {
           title: '操作',
           checked: true,
           key: 'action',
-          width: '200px',
+          width: '150px',
           align: 'center',
           scopedSlots: { customRender: 'action' }
         }
       ],
-      // 下拉框map
-      sourceMap: {},
-      levelMap: {},
-      statusMap: {},
-      needStopMap: {},
-      planFlagMap: {},
-      // 加载数据方法 必须为 Promise 对象
       loadData: parameter => {
         parameter = {
           ...parameter,
-          ...this.queryParam,
-          type: 2,
-          dataScope: {
-            sortBy: 'desc, asc',
-            sortName: 'apply_time, status'
-          }
+          ...this.queryParam
         }
-        return getRepairApplicationFormPage(Object.assign(parameter, this.queryParam))
+        return getRepairEntrustPage(parameter)
           .then(res => {
             return res.data
           })
-      },
-      selectedRowKeys: [],
-      selectedRows: [],
-
-      options: {
-        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
-        rowSelection: {
-          selectedRowKeys: this.selectedRowKeys,
-          onChange: this.onSelectChange
-        }
-      },
-      optionAlertShow: false
+      }
     }
   },
   created () {
-    // 下拉框map
-    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-    this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
-    this.planFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
-    this.tableOption()
+    this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
   },
   methods: {
-    tableOption () {
-      if (!this.optionAlertShow) {
-        this.options = {
-          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
-          rowSelection: {
-            selectedRowKeys: this.selectedRowKeys,
-            onChange: this.onSelectChange,
-            getCheckboxProps: record => ({
-              props: {
-                disabled: false,
-                name: record.id
-              }
-            })
-          }
-        }
-        this.optionAlertShow = true
-      } else {
-        this.options = {
-          alert: false,
-          rowSelection: null
-        }
-        this.optionAlertShow = false
-      }
-    },
-    batchDelete (id) {
-      let ids = []
-      if (this.BaseTool.String.isBlank(id)) {
-        const length = this.selectedRows.length
-        if (length === 0) {
-          this.$message.info('请选择要删除的记录')
-          return
-        }
-        ids = this.selectedRows.map(item => item.id)
-      } else {
-        ids = [id]
-      }
-      deleteRepairApplicationForms(ids).then(res => {
-        this.$message.info('删除成功')
-        this.handleOk()
-        this.$refs.table.clearSelected()
-      })
-    },
-    handleEdit (record) {
-      fetchRepairApplicationForm({ id: record.id }).then(res => {
-        const modal = this.$refs.baseModal
-        modal.base(res.data)
-      })
-    },
     handleView (record) {
-      fetchRepairApplicationForm({ id: record.id }).then(res => {
-        this.visible = false
-        const modal = this.$refs.detailOutModal
-        modal.base(res.data)
-      })
+      this.visible = false
+      const modal = this.$refs.detailOutModal
+      modal.base(record)
+    },
+    handleFinish (record) {
+      const modal = this.$refs.finishForm
+      modal.base(record)
     },
     handleOk () {
       this.visible = true
       this.$refs.table.refresh()
     },
-    onSelectChange (selectedRowKeys, selectedRows) {
-      this.selectedRowKeys = selectedRowKeys
-      this.selectedRows = selectedRows
-    },
     resetSearchForm () {
-      this.queryParam = {
-      }
+      this.queryParam = {}
       this.$refs.table.refresh(true)
-    },
-    doExport () {
-      const parameter = {
-        ...this.queryParam
-      }
-      exportRepairApplicationForm(parameter).then(file => {
-        this.BaseTool.UPLOAD.downLoadExportExcel(file)
-      })
-    },
-    handleDispatching (record) {
-      const modal = this.$refs.dispatchBaseForm
-      modal.base(record)
     }
   }
 }

+ 22 - 89
src/views/repair/application-form/modules/BaseOutForm.vue

@@ -10,30 +10,19 @@
     <a-form :form="form">
 
       <a-form-item v-show="false" >
-        <a-input v-decorator="['id']" type="hidden"/>
-      </a-form-item>
-      <a-form-item v-show="false">
-        <a-input v-decorator="['sbId']" type="hidden"/>
-      </a-form-item>
-      <a-form-item v-show="false">
-        <a-input v-decorator="['sbNo']" type="hidden"/>
-      </a-form-item>
-      <a-form-item v-show="false">
-        <a-input v-decorator="['sbName']" type="hidden"/>
-      </a-form-item>
-      <a-form-item v-show="false">
-        <a-input v-decorator="['mainRepairId']" type="hidden"/>
+        <a-input v-decorator="['repairId']" type="hidden"/>
       </a-form-item>
 
       <row-list :col="2">
         <row-item>
           <a-form-item
-            label="委外单号"
+            label="委外单号"
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
             <a-input
-              v-decorator="['outNo', {rules: [{required: false, message: '委外订单号不能为空'}]}]"/>
+              v-decorator="['entrustNo']"
+              placeholder="留空自动生成"/>
           </a-form-item>
         </row-item>
         <row-item>
@@ -58,7 +47,7 @@
             :labelCol="BaseTool.Constant.labelCol"
             :wrapperCol="BaseTool.Constant.wrapperCol"
           >
-            <a-select v-decorator="['repairUserId', {rules: [{required: true, message: '维修负责人不能为空'}]}]" placeholder="请选择">
+            <a-select v-decorator="['repairUserId', {rules: [{required: true, message: '维修负责人不能为空'}]}]" placeholder="请选择">
               <a-select-option
                 v-for="item in deptUserList"
                 :key="item.userId"
@@ -72,13 +61,13 @@
       <row-list :col="1">
         <row-item>
           <a-form-item
-            label="故障描述"
+            label="委外原因"
             :labelCol="BaseTool.Constant.labelCol2"
             :wrapperCol="BaseTool.Constant.wrapperCol2"
           >
             <a-textarea
               :rows="4"
-              v-decorator="['content']"/>
+              v-decorator="['reason', {rules: [{required: true, message: '委外原因不能为空'}]}]"/>
           </a-form-item>
         </row-item>
       </row-list>
@@ -90,88 +79,42 @@
 </template>
 
 <script>
-import pick from 'lodash.pick'
 import { queryUserDept } from '@/api/upms/user-dept'
-import { addRepairApplicationForm, updateRepairApplicationForm } from '@/api/repair/application-form'
-import PartInfoSelectModal from '@/views/part/info/modules/PartInfoSelectModal'
-import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
+import { createRepairEntrust } from '@/api/repair/entrust'
 
 export default {
-  name: 'BaseRepairApplicationForm',
+  name: 'BaseOutForm',
   data () {
     return {
       confirmLoading: false,
       modalTitle: null,
       form: this.$form.createForm(this),
       visible: false,
-      // 下拉框map
-      sourceMap: {},
       outTypeMap: {},
-      levelMap: {},
-      questionMap: {},
-      needStopMap: {},
-      statusMap: {},
       userInfo: this.$store.getters.userInfo,
       deptUserList: []
     }
   },
   components: {
-    SbInfoSelectModal,
-    PartInfoSelectModal
   },
   props: {
   },
   created () {
-    // 下拉框map
-    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-    this.questionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_QUESTION)
-    this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
     this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
     this.getDeptUsers()
   },
   methods: {
     base (record, mainForm = {}) {
       this.visible = true
-      // 如果是空标识添加
-      console.log(record, mainForm)
       const { form: { setFieldsValue } } = this
-      if (this.BaseTool.Object.isBlank(record)) {
-        this.modalTitle = '添加'
-        if (mainForm != null && mainForm.id != null) {
-          this.$nextTick(() => {
-            setFieldsValue({
-              sbId: mainForm.sbId,
-              sbNo: mainForm.sbNo,
-              sbName: mainForm.sbName,
-              mainRepairId: mainForm.id
-            })
+      this.modalTitle = '委外'
+      if (mainForm != null && mainForm.id != null) {
+        this.$nextTick(() => {
+          setFieldsValue({
+            repairId: mainForm.id
           })
-        }
-        return
+        })
       }
-      this.modalTitle = '编辑'
-      // 日期处理
-      this.$nextTick(() => {
-        setFieldsValue(Object.assign(pick(record, [
-          'id',
-          'sbId',
-          'partId',
-          'type',
-          'outType',
-          'mainRepairId',
-          'repairUserId',
-          'outNo',
-          'source',
-          'level',
-          'content',
-          'status',
-          'sbName',
-          'partName',
-          'remark'
-        ])))
-      })
     },
     getDeptUsers () {
       queryUserDept({ deptCode: this.DictCache.VALUE.SYS_DEPT_CODE.CHANG_NEI_WEI_XIU_ZU, userStatus: 1 }).then(res2 => {
@@ -186,29 +129,19 @@ export default {
           this.confirmLoading = false
           return
         }
-        values.type = 2
-        if (this.BaseTool.String.isBlank(values.id)) {
-          addRepairApplicationForm(values)
-            .then(() => {
-              this.handleCancel(true, values)
-            }).catch(() => {
-              this.confirmLoading = false
-            })
-        } else {
-          updateRepairApplicationForm(values)
-            .then(() => {
-              this.handleCancel(true, values)
-            }).catch(() => {
-              this.confirmLoading = false
-            })
-        }
+        createRepairEntrust(values)
+          .then(() => {
+            this.handleCancel(true, values)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
       })
     },
     handleCancel (isSave, values) {
       this.visible = false
       this.confirmLoading = false
       this.form.resetFields()
-      if (isSave && this.BaseTool.Object.isNotBlank(values)) {
+      if (isSave) {
         this.$emit('ok', values)
       }
     }

+ 86 - 3
src/views/repair/application-form/modules/DetailRepair.vue

@@ -11,7 +11,7 @@
               <a-button style="margin-left: 8px">接收</a-button>
             </a-popconfirm>
             <a-button v-if="$auth('repair-application-forms-deal') && (DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)" style="margin-left: 8px" @click="handleReject">拒单</a-button>
-            <a-button v-if="$auth('repair-application-forms-out') && (DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING >= model.status) && model.type != 2" style="margin-left: 8px" type="default" @click="handleOut">委外</a-button>
+            <a-button v-if="$auth('repair-application-forms-out') && (DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status) && model.type != 2" style="margin-left: 8px" type="default" @click="handleOut">委外</a-button>
             <a-button v-if="$auth('repair-application-forms-dispatch') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status" style="margin-left: 8px" type="default" @click="handleDispatch">转派</a-button>
             <a-button v-if="$auth('repair-application-forms-transfer') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status" style="margin-left: 8px" type="default" @click="handleTransfer">转派</a-button>
             <a-button v-if="$auth('repair-application-forms-finish') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status" style="margin-left: 8px" type="default" @click="handleFinish()">完成</a-button>
@@ -82,6 +82,19 @@
               暂无
             </detail-list-item>
           </detail-list>
+          <a-divider orientation="left">委外记录</a-divider>
+          <a-table :data-source="entrustList" :columns="columnsEntrust" tableLayout="auto" rowKey="id" v-if="entrustList.length > 0">
+            <span slot="entrustStatus" slot-scope="text">
+              <badge :text="text === 1 ? '委外维修中' : '已完成'" :status="text === 1 ? 'processing' : 'success'"/>
+            </span>
+            <span slot="entrustOutType" slot-scope="text">
+              {{ BaseTool.Object.getField(outTypeMap, text) }}
+            </span>
+            <span slot="entrustAction" slot-scope="record">
+              <a @click="handleViewEntrust(record)">查看</a>
+            </span>
+          </a-table>
+          <div v-if="entrustList.length === 0" style="margin-bottom: 16px; color: #999;">暂无委外记录</div>
           <a-divider v-if="dispatchList != null" orientation="left">转派详情</a-divider>
           <detail-list v-for="item in dispatchList" title="" :col="3">
             <detail-list-item term="转派人">{{ item.username }}</detail-list-item>
@@ -111,6 +124,7 @@
           </div>
         </a-layout-sider>
       </a-layout>
+      <!-- 隐藏备件清单/委外记录/维修报告整个标签区域
       <q-tabs :activeKey="activeKey" @change="changeTab">
         <q-tab-pane key="1" tab="备件清单">
           <div class="table-operator" v-if="$auth('repair-application-forms-finish')">
@@ -160,15 +174,16 @@
               <template>
                 <a @click="handleViewReason(record)">查看</a>
                 <operation-button @click="handleEditReason(record)">修改</operation-button>
-                <!--                <operation-button
+                <operation-button
                   v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)"
-                  @click="handleCopyReason(record)" >复制</operation-button>-->
+                  @click="handleCopyReason(record)" >复制</operation-button>
                 <operation-button :type="2" title="确认删除该记录?" @confirm="batchDeleteReason(record.id)">删除</operation-button>
               </template>
             </span>
           </a-table>
         </q-tab-pane>
       </q-tabs>
+      -->
       <!--      <title-divider title="备件清单" width="90px"></title-divider>
 
       <title-divider title="费用清单" width="90px"></title-divider>
@@ -201,6 +216,7 @@
     <detail-sb-check ref="detailSbCheckModal" @ok="handleOk" />
     <base-form ref="baseRepairProjectModal" @ok="handleOk" />
     <detail ref="detailRepairProjectModal" />
+    <detail-out ref="detailOutModal" @ok="handleOk" />
     <edit-form ref="editForm" @ok="handleOk" />
     <RejectForm ref="rejectForm" @ok="handleOk" />
     <transfer-form ref="transferForm" @ok="handleOk" />
@@ -210,6 +226,8 @@
 <script>
 import DetailList from '@/components/tools/DetailList'
 import { fetchRepairApplicationForm, examine, approve, receive } from '@/api/repair/application-form'
+import { getRepairEntrustByRepairId } from '@/api/repair/entrust'
+import DetailOut from './DetailRepairOut'
 import CheckForm from './CheckForm'
 import RejectForm from './RejectForm'
 import BaseOutForm from './BaseOutForm'
@@ -273,6 +291,7 @@ export default {
     BaseForm,
     Detail,
     RejectForm,
+    DetailOut,
   },
   data() {
     return {
@@ -296,6 +315,43 @@ export default {
       repairTechnologyMap: {},
       activeKey: 'a',
       data: [],
+      entrustList: [],
+      outTypeMap: {},
+      columnsEntrust: [
+        {
+          title: '序号',
+          dataIndex: 'index',
+          customRender: (text, record, index) => `${index + 1}`,
+        },
+        {
+          title: '委外单号',
+          dataIndex: 'entrustNo',
+        },
+        {
+          title: '委外类别',
+          dataIndex: 'outType',
+          scopedSlots: { customRender: 'entrustOutType' },
+        },
+        {
+          title: '委外维修人',
+          dataIndex: 'repairUserName',
+        },
+        {
+          title: '状态',
+          dataIndex: 'status',
+          scopedSlots: { customRender: 'entrustStatus' },
+        },
+        {
+          title: '创建时间',
+          dataIndex: 'createdTime',
+        },
+        {
+          title: '操作',
+          key: 'action',
+          width: '100px',
+          scopedSlots: { customRender: 'entrustAction' },
+        },
+      ],
       dataSpare: [],
       dataFee: [],
       dataReason: [],
@@ -501,6 +557,7 @@ export default {
     this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_FEE_TYPE)
     this.typeReasonMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_REASON_TYPE)
     this.planFlagMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
+    this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
   },
   methods: {
     base(record) {
@@ -509,6 +566,9 @@ export default {
       this.modalTitle = '详情'
       this.model = record
       this.activeKey = 'a'
+      this.entrustList = []
+      // 收起上一条工单可能残留的委外详情卡片
+      this.closeEntrustDetail()
       this.dispatchList = JSON.parse(record.repairDispatchList)
       const sbId = record.sbId
       if (sbId) {
@@ -533,6 +593,17 @@ export default {
       queryRepairReason({ repairId: this.model.id }).then((res) => {
         this.dataReason = res.data
       })
+      const repairId = this.model.id
+      getRepairEntrustByRepairId(repairId).then((res) => {
+        // 防止异步返回时已切换到其他工单
+        if (this.model.id === repairId) {
+          this.entrustList = res.data || []
+        }
+      }).catch(() => {
+        if (this.model.id === repairId) {
+          this.entrustList = []
+        }
+      })
     },
     handleViewBom(record) {
       this.visible = false
@@ -547,8 +618,16 @@ export default {
     handleCancel() {
       this.visible = false
       this.confirmLoading = false
+      // 退出工单时同步收起委外详情卡片,避免返回列表后仍显示
+      this.closeEntrustDetail()
       this.$emit('ok')
     },
+    // 收起委外详情卡片(避免切换工单时残留上一条工单的委外详情)
+    closeEntrustDetail() {
+      if (this.$refs.detailOutModal) {
+        this.$refs.detailOutModal.visible = false
+      }
+    },
     receive() {
       this.model.status = this.DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING
       receive(this.model).then(() => {
@@ -577,6 +656,10 @@ export default {
       const modal = this.$refs.outForm
       modal.base(null, this.model)
     },
+    handleViewEntrust(record) {
+      const modal = this.$refs.detailOutModal
+      modal.base(record)
+    },
     handleAddFee() {
       const modal = this.$refs.feeForm
       modal.base(null, this.model)

+ 58 - 478
src/views/repair/application-form/modules/DetailRepairOut.vue

@@ -4,542 +4,122 @@
       <a-row :gutter="48" slot="extra">
         <a-col :md="48" :sm="48">
           <span class="table-page-search-submitButtons" style="float: right">
-            <a-popconfirm v-if="$auth('repair-application-forms-deal') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status" title="是否要接收?" @confirm="receive">
-              <a-button>接收</a-button>
-            </a-popconfirm>
-            <!--            <a-button v-if="DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status" style="margin-left: 8px" type="primary" @click="handleEdit()">编辑</a-button>-->
-            <a-button v-if="$auth('repair-application-forms-finish') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status" style="margin-left: 8px" type="primary" @click="handleFinish()">委外维修完成</a-button>
-            <!--          <a-button v-if="$auth('repair-application-forms-finish') && DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status" style="margin-left: 8px" type="primary" @click="handleSparePick">领用备件</a-button>-->
+            <a-button
+              v-if="DictCache.VALUE.REPAIR_ENTRUST_STATUS && model.status === 1"
+              style="margin-left: 8px"
+              type="primary"
+              @click="handleFinish()">完成</a-button>
             <a-button style="margin-left: 8px" @click="handleCancel">返回</a-button>
           </span>
         </a-col>
       </a-row>
       <a-layout>
         <a-layout-content style="background-color: rgb(255, 255, 255)">
-          <a-divider orientation="left">委外详情</a-divider>
+          <a-divider orientation="left">委外基本信息</a-divider>
           <detail-list title="" :col="3">
-            <detail-list-item term="委外单号">{{ model.no }}</detail-list-item>
+            <detail-list-item term="委外单号">{{ model.entrustNo }}</detail-list-item>
+            <detail-list-item term="工单号">{{ model.repairNo }}</detail-list-item>
             <detail-list-item term="委外类别">{{ outTypeMap[model.outType] }}</detail-list-item>
-            <detail-list-item term="委外时间">{{ model.applyTime }}</detail-list-item>
-            <detail-list-item term="委外状态"><badge :text="BaseTool.Object.getField(statusMap,model.status)" :status="DictCache.COLOR.REPAIR_APPLICATION_FORM_STATUS[model.status]"/></detail-list-item>
+            <detail-list-item term="委外申请人">{{ model.entrustUserName }}</detail-list-item>
+            <detail-list-item term="委外维修人">{{ model.repairUserName }}</detail-list-item>
+            <detail-list-item term="设备名称">{{ model.sbName }}</detail-list-item>
+            <detail-list-item term="设备编号">{{ model.sbNo }}</detail-list-item>
+            <detail-list-item term="委外状态">
+              <badge :text="entrustStatusMap[model.status]" :status="model.status === 1 ? 'processing' : 'success'"/>
+            </detail-list-item>
+            <detail-list-item term="创建时间">{{ model.createdTime }}</detail-list-item>
           </detail-list>
           <detail-list title="" :col="1">
-            <!--<detail-list-item term="故障描述">{{ BaseTool.Object.getField(this.descripitionMap, model.content) }}</detail-list-item>-->
-            <detail-list-item term="故障描述">{{ model.content }}</detail-list-item>
+            <detail-list-item term="委外原因">{{ model.reason }}</detail-list-item>
           </detail-list>
-          <detail-list title="" :col="1">
-            <detail-list-item term="维修描述">{{ model.repairContent }}</detail-list-item>
+
+          <a-divider orientation="left" v-if="model.status === 2">完成信息</a-divider>
+          <detail-list title="" :col="3" v-if="model.status === 2">
+            <detail-list-item term="完成时间">{{ model.finishTime }}</detail-list-item>
           </detail-list>
-          <detail-list title="维修图片:" :col="6">
-            <upload-image-detail :images-list="model.repairFileList"/>
+          <detail-list title="" :col="1" v-if="model.status === 2">
+            <detail-list-item term="维修情况">{{ model.finishRemark }}</detail-list-item>
           </detail-list>
-          <a-divider orientation="left">审核详情</a-divider>
-          <detail-list title="" :col="3">
-            <detail-list-item term="审核开始时间">{{ model.checkStartTime }}</detail-list-item>
-            <detail-list-item term="审核结束时间">{{ model.checkEndTime }}</detail-list-item>
-            <detail-list-item term="审核人员">{{ model.checkUserName }}</detail-list-item>
-            <detail-list-item term="审核描述">{{ model.checkContent }}</detail-list-item>
-          </detail-list>
-          <detail-list title="审核图片:" :col="6">
-            <upload-image-detail :images-list="model.checkFileList"/>
+          <detail-list title="完成图片:" :col="6" v-if="model.status === 2 && model.finishFileList && model.finishFileList.length > 0">
+            <upload-image-detail :images-list="model.finishFileList"/>
           </detail-list>
+          <div v-if="model.status === 2 && model.finishAttachmentList && model.finishAttachmentList.length > 0" style="margin-bottom: 16px;">
+            <div style="font-weight: bold; margin-bottom: 8px; color: rgba(0, 0, 0, 0.85);">完成附件:</div>
+            <div v-for="file in model.finishAttachmentList" :key="file.id" style="margin-bottom: 4px;">
+              <a-icon type="paper-clip" />
+              <a @click="handleDownloadFile(file)" style="margin-left: 4px;">{{ file.name }}</a>
+            </div>
+          </div>
         </a-layout-content>
       </a-layout>
-      <title-divider title="费用清单" width="90px"></title-divider>
-      <div class="table-operator" v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)">
-        <a-button type="primary" @click="handleAddFee">
-          <a-icon type="plus"/>
-          添加
-        </a-button>
-      </div>
-      <a-table
-        :data-source="dataFee"
-        :columns="columnsFee"
-        tableLayout="auto"
-        rowKey="id">
-        <span slot="action" slot-scope="record">
-          <template>
-            <a @click="handleViewFee(record)">查看</a>
-            <operation-button
-              v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)"
-              @click="handleEditFee(record)" >修改</operation-button>
-
-            <operation-button
-              v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)"
-              :type="2"
-              title="确认删除该笔费用?"
-              @confirm="batchDeleteFee(record.id)" >删除</operation-button>
-          </template>
-        </span>
-      </a-table>
-      <!--      <title-divider title="维修报告" width="90px"></title-divider>-->
-      <!--      <div class="table-operator" v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)">-->
-      <!--        <a-button type="primary" @click="handleAddReason">-->
-      <!--          <a-icon type="plus"/>-->
-      <!--          添加-->
-      <!--        </a-button>-->
-      <!--      </div>-->
-      <!--      <a-table-->
-      <!--        :data-source="dataReason"-->
-      <!--        :columns="columnsReason"-->
-      <!--        tableLayout="fixed"-->
-      <!--        rowKey="id">-->
-      <!--        <span slot="action" slot-scope="record">-->
-      <!--          <template>-->
-      <!--            <a @click="handleViewReason(record)">查看</a>-->
-      <!--            <operation-button-->
-      <!--              v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)"-->
-      <!--              @click="handleEditReason(record)" >修改</operation-button>-->
-
-      <!--            <operation-button-->
-      <!--              v-if="$auth('repair-application-forms-finish') && ( DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING === model.status || DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REBACK === model.status)"-->
-      <!--              :type="2"-->
-      <!--              title="确认删除该记录?"-->
-      <!--              @confirm="batchDeleteReason(record.id)" >删除</operation-button>-->
-      <!--          </template>-->
-      <!--        </span>-->
-      <!--      </a-table>-->
-
     </a-card>
-    <check-form ref="checkForm" @ok="handleOk" />
-    <base-out-form ref="outForm" @ok="handleOk" />
     <finish-form ref="finishForm" @ok="handleOk" />
-    <dispatch-form ref="dispatchForm" @ok="handleCancel" />
-    <assign-form ref="assignForm" @ok="handleCancel" />
-    <spare-pick-base-form ref="baseModal" @ok="handleOk"/>
-    <!--    <repair-project-select-Modal :type="'checkbox'" ref="repairProjectSelectModal" @selected="handleRepairProjectSelected"/>-->
-    <!--    <spare-part-info-select-modal :type="'checkbox'" ref="spareSelectModal" @selected="handleSpareSelected"/>-->
-    <base-form-for-repair ref="baseFormForRepair" @ok="handleOk" />
-    <!--    <spare-store-select-modal ref="spareStoreSelectModal" @selected="handleSpareStoreSelected"/>-->
-    <fee-base-form ref="feeForm" @ok="handleOk" />
-    <fee-detail ref="feeDetail" @ok="handleOk" />
-    <reason-base-form ref="reasonForm" @ok="handleOk" />
-    <reason-detail ref="reasonDetail" @ok="handleOk" />
   </div>
 </template>
 
 <script>
 import DetailList from '@/components/tools/DetailList'
-import { fetchRepairApplicationForm, approve, receive } from '@/api/repair/application-form'
-import CheckForm from './CheckForm'
-import BaseOutForm from './BaseOutForm'
+import { fetchRepairEntrust } from '@/api/repair/entrust'
 import FinishForm from './FinishOutForm'
-import DispatchForm from './DispatchForm'
-import AssignForm from './AssignForm'
-import SparePickBaseForm from '../../../store/sparepickform/modules/BaseForm'
-import SparePartUsedSelectTable from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectTable'
-import SparePickFormSelectTable from '@/views/store/sparepickform/modules/SparePickFormSelectTable'
-import RepairProjectSelectModal from '@/views/repair/repairproject/modules/RepairProjectSelectModal'
-import { selectRepairProjectListByRepairId, addRepairProjectRelationBatch, deleteRepairProjectRelations } from '@/api/repair/repairprojectrelation'
-import SparePartInfoSelectModal from '@/views/sqarepartmanage/sparepartinfo/modules/SparePartInfoSelectModal'
-import BaseFormForRepair from '@/views/sqarepartmanage/sparepartused/modules/BaseFormForRepair'
-import { selectSparePartUsedListByRepairId, addSparePartUsedBatch, deleteSparePartUseds } from '@/api/sqarepartmanage/sparepartused'
-import SpareStoreSelectModal from '@/views/store/sparestore/modules/SpareStoreSelectModal'
-import BaseTool from '@/utils/tool'
-import FeeBaseForm from '@/views/repair/fee/modules/BaseForm'
-import FeeDetail from '@/views/repair/fee/modules/Detail'
-import { deleteRepairFees, fetchRepairFee, queryRepairFee } from '@/api/repair/fee'
-import ReasonBaseForm from '@/views/repair/repair-reason/modules/BaseForm'
-import ReasonDetail from '@/views/repair/repair-reason/modules/Detail'
-import { deleteRepairReasons, fetchRepairReason, queryRepairReason } from '@/api/repair/repair-reason'
 
 const DetailListItem = DetailList.Item
 
 export default {
-  name: 'RepairApplicationFormDetail',
+  name: 'DetailRepairOut',
   components: {
-    CheckForm,
     DetailList,
-    ReasonBaseForm,
-    ReasonDetail,
     DetailListItem,
-    FinishForm,
-    BaseOutForm,
-    DispatchForm,
-    FeeDetail,
-    AssignForm,
-    FeeBaseForm,
-    SparePickBaseForm,
-    SparePartUsedSelectTable,
-    SparePickFormSelectTable,
-    RepairProjectSelectModal,
-    SparePartInfoSelectModal,
-    BaseFormForRepair,
-    SpareStoreSelectModal
+    FinishForm
   },
   data () {
     return {
       confirmLoading: false,
-      mdl: {},
-      modalTitle: null,
-      needStopMap: {},
-      dispatchList: [],
+      modalTitle: '委外详情',
       visible: false,
-      // 下拉框map
-      sourceMap: {},
       outTypeMap: {},
-      typeMap: {},
-      levelMap: {},
-      descripitionMap: {},
-      selectedRowKeys: [],
-      statusMap: {},
-      repairProjectMap: {},
-      repairTechnologyMap: {},
-      activeKey: 'a',
-      data: [],
-      dataSpare: [],
-      dataFee: [],
-      dataReason: [],
-      // 表头
-      columns: [
-        {
-          title: '序号',
-          dataIndex: 'index',
-          customRender: (text, record, index) => {
-            return `${index + 1}`
-          }
-        },
-        {
-          title: '编码',
-          dataIndex: 'no'
-        },
-        {
-          title: '名称',
-          dataIndex: 'name'
-        },
-        {
-          title: '维修类别',
-          dataIndex: 'type',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Object.getField(this.repairProjectMap, text)
-          }
-        },
-        {
-          title: '维修工艺',
-          dataIndex: 'technology',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Object.getField(this.repairTechnologyMap, text)
-          }
-        },
-        {
-          title: '标准工时',
-          dataIndex: 'standardHours'
-        },
-        {
-          title: '标准费用',
-          dataIndex: 'standardMoney'
-        },
-        {
-          title: '考核工时',
-          dataIndex: 'checkHours'
-        },
-        {
-          title: '操作',
-          key: 'action',
-          width: '200px',
-          align: 'center',
-          scopedSlots: { customRender: 'action' }
-        }
-      ],
-      columnsSpare: [
-        {
-          title: '序号',
-          dataIndex: 'index',
-          customRender: (text, record, index) => {
-            return `${index + 1}`
-          }
-        },
-        {
-          title: '备件名称',
-          dataIndex: 'spareId',
-          customRender: (text, record, index) => {
-            return record.spareName
-          }
-        },
-        {
-          title: '数量',
-          dataIndex: 'num'
-        },
-        {
-          title: '价格',
-          dataIndex: 'price'
-        },
-        {
-          title: '总价',
-          dataIndex: 'totalPrice'
-        },
-        {
-          title: '更换日期',
-          dataIndex: 'startDate'
-        },
-        {
-          title: '操作',
-          key: 'action',
-          width: '200px',
-          align: 'center',
-          scopedSlots: { customRender: 'actionSpare' }
-        }
-      ],
-      columnsFee: [
-        {
-          title: '序号',
-          dataIndex: 'index',
-          customRender: (text, record, index) => {
-            return `${index + 1}`
-          }
-        },
-        {
-          title: '费用金额',
-          dataIndex: 'fee',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Amount.formatter(text)
-          }
-        },
-        {
-          title: '费用类别',
-          dataIndex: 'type',
-          customRender: (text, record, index) => {
-            return this.BaseTool.Object.getField(this.typeMap, text)
-          }
-        },
-        {
-          title: '费用原因',
-          dataIndex: 'reason'
-        },
-        {
-          title: '费用描述',
-          dataIndex: 'descripition'
-        },
-        {
-          title: '备注',
-          dataIndex: 'remark'
-        },
-        {
-          title: '操作',
-          key: 'action',
-          width: '200px',
-          align: 'center',
-          scopedSlots: { customRender: 'action' }
-        }
-      ],
-      columnsReason: [
-        {
-          title: '序号',
-          dataIndex: 'index',
-          width: '70',
-          customRender: (text, record, index) => {
-            return `${index + 1}`
-          }
-        },
-        {
-          title: '分析时间',
-          dataIndex: 'analyzeTime',
-          width: '200px'
-        },
-        {
-          title: '问题描述',
-          dataIndex: 'problemDesc',
-          ellipsis: true,
-          width: '200px'
-        },
-        {
-          title: '维修报告',
-          dataIndex: 'reasonAnalysis',
-          ellipsis: true,
-          width: '200px'
-        },
-        {
-          title: '改进措施',
-          dataIndex: 'improveMeasure',
-          ellipsis: true,
-          width: '200px'
-        },
-        {
-          title: '操作',
-          key: 'action',
-          width: '200px',
-          align: 'center',
-          scopedSlots: { customRender: 'action' }
-        }
-      ],
-      model: {
-        'id': null,
-        'sbId': null,
-        'partId': null,
-        'repairUserId': null,
-        'needStop': null,
-        'no': null,
-        'source': null,
-        'applyTime': null,
-        'limitHours': null,
-        'limitDate': null,
-        'level': null,
-        'content': null,
-        'status': null,
-        'remark': null,
-        'updateTime': null,
-        'createdUserId': null,
-        'updateUserId': null,
-        'createdUserName': null,
-        'sbName': null,
-        'partName': null,
-        'updateUserName': null,
-        'repairFormVO': null,
-        'repairCheckVO': null
-      }
+      entrustStatusMap: {
+        1: '委外维修中',
+        2: '已完成'
+      },
+      model: {}
     }
   },
   created () {
-    // 下拉框map
-    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-    this.statusRepairMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_FORM_STATUS)
-    this.statusCheckMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_CHECK_STATUS)
-    this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
-    this.repairProjectMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_PROJECT_TYPE)
-    this.repairTechnologyMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_TECHNOLOGY_TYPE)
-    this.descripitionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIRE_ACTION)
-    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_FEE_TYPE)
     this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
   },
   methods: {
     base (record) {
       this.visible = true
-      this.modalTitle = '详情'
       this.model = record
-      this.activeKey = 'a'
-      this.dispatchList = JSON.parse(record.repairDispatchList)
-      this.init()
+      this.loadDetail(record.id)
     },
-    init () {
-      queryRepairFee({ repairId: this.model.id }).then(res => {
-        this.dataFee = res.data
-      })
-      queryRepairReason({ repairId: this.model.id }).then(res => {
-        this.dataReason = res.data
+    loadDetail (id) {
+      fetchRepairEntrust(id).then(res => {
+        this.model = res.data
       })
     },
+    handleDownloadFile (file) {
+      const baseUrl = process.env.VUE_APP_API_BASE_URL || ''
+      const link = document.createElement('a')
+      link.href = baseUrl + file.url
+      link.download = file.name || '下载'
+      link.target = '_blank'
+      document.body.appendChild(link)
+      link.click()
+      document.body.removeChild(link)
+    },
     handleCancel () {
       this.visible = false
       this.confirmLoading = false
       this.$emit('ok')
     },
-    receive () {
-      this.model.status = this.DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.PROCESSING
-      receive(this.model).then(() => {
-        // const modal = this.$refs.finishForm
-        // modal.base(that.model)
-      })
-    },
-    batchDeleteFee (id) {
-      let ids = []
-      if (this.BaseTool.String.isBlank(id)) {
-        const length = this.selectedRows.length
-        if (length === 0) {
-          this.$message.info('请选择要删除的记录')
-          return
-        }
-        ids = this.selectedRows.map(item => item.id)
-      } else {
-        ids = [id]
-      }
-      deleteRepairFees(ids).then(res => {
-        this.$message.info('删除成功')
-        this.handleOk()
-      })
-    },
-    handleAddFee () {
-      const modal = this.$refs.feeForm
-      modal.base(null, this.model)
-    },
-    handleEditFee (record) {
-      fetchRepairFee({ id: record.id }).then(res => {
-        const modal = this.$refs.feeForm
-        const data = res.data
-        data.repairNo = this.model.no
-        modal.base(data, this.model)
-      })
-    },
-    handleViewFee (record) {
-      fetchRepairFee({ id: record.id }).then(res => {
-        const modal = this.$refs.feeDetail
-        modal.base(res.data)
-      })
-    },
-    batchDeleteReason (id) {
-      let ids = []
-      if (this.BaseTool.String.isBlank(id)) {
-        const length = this.selectedRows.length
-        if (length === 0) {
-          this.$message.info('请选择要删除的记录')
-          return
-        }
-        ids = this.selectedRows.map(item => item.id)
-      } else {
-        ids = [id]
-      }
-      deleteRepairReasons(ids).then(res => {
-        this.$message.info('删除成功')
-        this.handleOk()
-        this.$refs.table.clearSelected()
-      })
-    },
-    handleAddReason () {
-      const modal = this.$refs.reasonForm
-      this.visible = false
-      modal.base(null, this.model)
-    },
-    handleEditReason (record) {
-      fetchRepairReason({ id: record.id }).then(res => {
-        const modal = this.$refs.reasonForm
-        this.visible = false
-        modal.base(res.data, this.model)
-      })
-    },
-    handleViewReason (record) {
-      fetchRepairReason({ id: record.id }).then(res => {
-        const modal = this.$refs.reasonDetail
-        modal.base(res.data)
-      })
-    },
-    handleOk () {
-      this.loading = true
-      fetchRepairApplicationForm({ id: this.model.id }).then(res => {
-        this.loading = false
-        this.model = res.data
-        this.visible = true
-        this.dispatchList = JSON.parse(this.model.repairDispatchList)
-      })
-      this.init()
-    },
-    handleEdit () {
-      const modal = this.$refs.finishForm
-      modal.base(this.model)
-    },
     handleFinish () {
       const modal = this.$refs.finishForm
       modal.base(this.model)
     },
-    batchDelete (id) {
-      let ids = []
-      if (this.BaseTool.String.isBlank(id)) {
-        if (length === 0) {
-          this.$message.info('请选择要删除的记录')
-          return
-        }
-        ids = this.selectedRows.map(item => item.id)
-      } else {
-        ids = [id]
-      }
-      deleteRepairProjectRelations(ids).then(res => {
-        this.$message.info('删除成功')
-        this.handleOk()
-      })
-    },
-    onSelectChange (selectedRowKeys) {
-      console.log('selectedRowKeys changed: ', selectedRowKeys)
-      this.selectedRowKeys = selectedRowKeys
+    handleOk () {
+      this.loadDetail(this.model.id)
+      this.$emit('ok')
     }
   }
 }

+ 47 - 143
src/views/repair/application-form/modules/FinishOutForm.vue

@@ -12,172 +12,121 @@
         <a-input v-decorator="['id']" type="hidden"/>
       </a-form-item>
 
-      <row-list :col="2">
-        <row-item>
-          <a-form-item
-            label="委外订单号"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
-            <a-input
-              disabled="disabled"
-              v-decorator="['no', {rules: [{required: false, message: '委外订单号不能为空'}]}]"/>
-          </a-form-item>
-        </row-item>
-        <row-item>
-          <a-form-item
-            label="委外类别"
-            :labelCol="BaseTool.Constant.labelCol"
-            :wrapperCol="BaseTool.Constant.wrapperCol"
-          >
-            <a-select v-decorator="['outType']" placeholder="请选择">
-              <a-select-option
-                v-for="(label,value) in outTypeMap"
-                :key="value"
-                :label="label"
-                :value="parseInt(value)">{{ label }}
-              </a-select-option>
-            </a-select>
-          </a-form-item>
-        </row-item>
-      </row-list>
       <row-list :col="1">
         <row-item>
           <a-form-item
-            label="故障描述"
+            label="维修情况"
             :labelCol="BaseTool.Constant.labelCol2"
             :wrapperCol="BaseTool.Constant.wrapperCol2"
           >
-            <a-textarea v-decorator="['content', {rules: [{required: true, message: '故障描述不能为空'}]}]"/>
+            <a-textarea
+              :rows="4"
+              v-decorator="['finishRemark', {rules: [{required: true, message: '维修情况不能为空'}]}]"/>
           </a-form-item>
         </row-item>
-      </row-list>
-      <row-list :col="1">
         <row-item>
           <a-form-item
-            label="维修描述"
+            label="上传图片"
             :labelCol="BaseTool.Constant.labelCol2"
             :wrapperCol="BaseTool.Constant.wrapperCol2"
           >
-            <a-textarea v-decorator="['repairContent', {rules: [{required: true, message: '维修描述不能为空'}]}]"/>
+            <a-upload
+              :action="uploadUrl"
+              :multiple="true"
+              list-type="picture"
+              :file-list="defaultFinishFileList"
+              @change="handleFinishFileChange"
+              accept="image/*"
+              :headers="headers"
+            >
+              <a-button> <a-icon type="upload" /> 上传图片 </a-button>
+            </a-upload>
           </a-form-item>
         </row-item>
         <row-item>
           <a-form-item
-            label="维修图片"
+            label="上传附件"
             :labelCol="BaseTool.Constant.labelCol2"
             :wrapperCol="BaseTool.Constant.wrapperCol2"
           >
             <a-upload
               :action="uploadUrl"
               :multiple="true"
-              list-type="picture"
-              :file-list="defaultRepairFileList"
-              @change="handleRepairFileChange"
-              accept="image/*"
+              :file-list="defaultAttachmentList"
+              @change="handleAttachmentChange"
               :headers="headers"
             >
-              <a-button> <a-icon type="upload" /> 上传图片 </a-button>
+              <a-button> <a-icon type="upload" /> 上传附件 </a-button>
             </a-upload>
           </a-form-item>
         </row-item>
       </row-list>
     </a-form>
-    <spare-part-used-select-modal ref="sparePartUsedSelectModal" />
     <template slot="footer">
-      <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
+      <a-button :loading="confirmLoading" type="primary" @click="save()">完成</a-button>
     </template>
   </a-modal>
 </template>
 
 <script>
-import pick from 'lodash.pick'
-import { finish } from '@/api/repair/application-form'
-import { queryUser } from '@/api/upms/user'
-import { fetchErrorTypeTree } from '@/api/repair/errortype'
-import SparePartUsedSelectModal from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectModal'
+import { finishRepairEntrust } from '@/api/repair/entrust'
 import { uploadUrl } from '@/api/upms/file'
 import Vue from 'vue'
 import { ACCESS_TOKEN } from '@/store/mutation-types'
 
 export default {
-  name: 'BaseRepairApplicationForm',
+  name: 'FinishOutForm',
   data () {
     return {
       model: null,
       confirmLoading: false,
-      modalTitle: null,
+      modalTitle: '委外完成',
       form: this.$form.createForm(this),
       visible: false,
-      // 下拉框map
-      treeData: [],
-      descripitionMap: {},
-      sourceMap: {},
-      outTypeMap: {},
-      levelMap: {},
-      needStopMap: {},
-      statusMap: {},
       headers: {
         Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
       },
       uploadUrl: uploadUrl,
-      defaultRepairFileList: [],
-      repairFileList: [], // 维修图片,
-      userList: []
+      defaultFinishFileList: [],
+      defaultAttachmentList: [],
+      finishFileList: [],
+      finishAttachmentList: []
     }
   },
   components: {
-    SparePartUsedSelectModal
-  },
-  props: {
   },
   created () {
-    // 下拉框map
-    this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
-    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
-    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
-    this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
-    this.descripitionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIRE_ACTION)
-    this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
   },
   methods: {
     base (record) {
-      this.setTree()
       this.visible = true
       this.model = record
-      // 如果是空标识添加
-      if (this.BaseTool.Object.isBlank(record)) {
-        this.modalTitle = '添加'
-        return
-      }
-      this.modalTitle = '委外完成'
+      this.defaultFinishFileList = []
+      this.defaultAttachmentList = []
+      this.finishFileList = []
+      this.finishAttachmentList = []
       const { form: { setFieldsValue } } = this
-      // 日期处理
       this.$nextTick(() => {
-        setFieldsValue(Object.assign(pick(record, [
-          'id',
-          'no',
-          'outType',
-          'content'
-        ])))
+        setFieldsValue({
+          id: record.id
+        })
       })
     },
-    getUsers () {
-      queryUser({ status: 1 }).then(res => {
-        this.userList = res.data
-      })
+    handleFinishFileChange (info) {
+      this.defaultFinishFileList = info.fileList
+      this.finishFileList = this.setFileList(info)
     },
-    handleRepairFileChange (info) {
-      this.defaultRepairFileList = info.fileList
-      this.repairFileList = this.setFileList(info, 12)
+    handleAttachmentChange (info) {
+      this.defaultAttachmentList = info.fileList
+      this.finishAttachmentList = this.setFileList(info)
     },
-    setFileList (info, type) {
+    setFileList (info) {
       const file = info.file
       const fileList = info.fileList
       if (file.status === 'done') {
-        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
+        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, 12)
       } else if (file.status === 'removed') {
-        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
+        return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, 12)
       } else if (file.status === 'error') {
         this.$message.error('上传失败')
         return []
@@ -191,10 +140,9 @@ export default {
           this.confirmLoading = false
           return
         }
-        // 日期处理
-        values.repairFileList = this.repairFileList
-        console.log(values)
-        finish(values).then(() => {
+        values.finishFileList = this.finishFileList
+        values.finishAttachmentList = this.finishAttachmentList
+        finishRepairEntrust(values.id, values).then(() => {
           this.handleCancel(values)
         }).catch(() => {
           this.confirmLoading = false
@@ -208,51 +156,7 @@ export default {
       if (this.BaseTool.Object.isNotBlank(values)) {
         this.$emit('ok')
       }
-    },
-    handleSbSelect () {
-      this.$refs.sbInfoSelectModal.base({}, { filter: 0, status: 2 })
-    },
-    handleSbSelectd (keys, rows) {
-      const [ key ] = keys
-      const [ row ] = rows
-      const { form: { setFieldsValue } } = this
-      // 日期处理
-      this.$nextTick(() => {
-        setFieldsValue(Object.assign({
-          'sbId': key,
-          'sbName': row.name
-        }))
-      })
-    },
-    handlePartSelect () {
-      const sbId = this.form.getFieldValue('sbId')
-      this.$refs.partInfoSelectModal.base({ sbId })
-    },
-    handlePartSelected (keys, rows) {
-      const [ key ] = keys
-      const [ row ] = rows
-      const { form: { setFieldsValue } } = this
-      this.$nextTick(() => {
-        setFieldsValue(Object.assign({
-          'partId': key,
-          'partName': row.name
-        }))
-      })
-    },
-    /**
-     * 设置类别树
-     */
-    setTree (record = {}) {
-      fetchErrorTypeTree({ id: record.id }).then(res => {
-        this.treeData = res.data
-      })
-    },
-    handleAddPartUsed () {
-      /* const modal = this.$refs.repairFeeModal
-      modal.base(null, record) */
-      this.$refs.sparePartUsedSelectModal.base(this.model, { sbId: this.model.sbId, modelId: this.model.modelId })
     }
-
   }
 }
 </script>