BaseForm.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="900"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-form :form="form">
  11. <a-form-item v-show="false" >
  12. <a-input v-decorator="['id']" type="hidden"/>
  13. <a-input v-decorator="['sbId']" type="hidden"/>
  14. <a-input v-decorator="['partId']" type="hidden"/>
  15. </a-form-item>
  16. <row-list :col="2">
  17. <row-item>
  18. <a-form-item
  19. label="录入方式"
  20. :labelCol="BaseTool.Constant.labelCol"
  21. :wrapperCol="BaseTool.Constant.wrapperCol"
  22. >
  23. <a-radio-group v-decorator="['inputType', {initialValue: 2}]" button-style="solid" @change="inputTypeChange">
  24. <a-radio-button :value="2">
  25. 选择录入
  26. </a-radio-button>
  27. <a-radio-button :value="1">
  28. 手动录入
  29. </a-radio-button>
  30. </a-radio-group>
  31. </a-form-item>
  32. </row-item>
  33. <row-item v-if="inputType===2">
  34. <a-form-item
  35. label="设备名称"
  36. :labelCol="BaseTool.Constant.labelCol"
  37. :wrapperCol="BaseTool.Constant.wrapperCol"
  38. >
  39. <a-input
  40. style="width: 70%"
  41. disabled
  42. v-decorator="['sbName', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  43. <a-button style="width: 30%" type="primary" @click="handleSbSelect">选择</a-button>
  44. </a-form-item>
  45. </row-item>
  46. <row-item v-else>
  47. <a-form-item
  48. label="设备名称"
  49. :labelCol="BaseTool.Constant.labelCol"
  50. :wrapperCol="BaseTool.Constant.wrapperCol"
  51. >
  52. <a-input
  53. v-decorator="['sbName']" />
  54. </a-form-item>
  55. </row-item>
  56. <row-item v-if="inputType===1">
  57. <a-form-item
  58. label="设备位号"
  59. :labelCol="BaseTool.Constant.labelCol"
  60. :wrapperCol="BaseTool.Constant.wrapperCol"
  61. >
  62. <a-input
  63. v-decorator="['positionNo', {rules: [{required: true, message: '设备位号不能为空'}]}]" />
  64. </a-form-item>
  65. </row-item>
  66. <!-- <row-item>
  67. <a-form-item
  68. label="机电仪位号"
  69. :labelCol="BaseTool.Constant.labelCol"
  70. :wrapperCol="BaseTool.Constant.wrapperCol"
  71. >
  72. <a-input v-decorator="['parentSbNo']" />
  73. </a-form-item>
  74. </row-item> -->
  75. <!-- <row-item>
  76. <a-form-item
  77. label="设备部位"
  78. :labelCol="BaseTool.Constant.labelCol"
  79. :wrapperCol="BaseTool.Constant.wrapperCol"
  80. >
  81. <a-input
  82. style="width: 70%"
  83. disabled
  84. v-decorator="['partName']" />
  85. <a-button style="width: 30%" type="primary" @click="handlePartSelect">选择</a-button>
  86. </a-form-item>
  87. </row-item>-->
  88. <!-- <row-item>
  89. <a-form-item
  90. label="委托单位"
  91. :labelCol="BaseTool.Constant.labelCol"
  92. :wrapperCol="BaseTool.Constant.wrapperCol"
  93. >
  94. <a-select v-decorator="['trustDept', {rules: [{required: true, message: '委托单位不能为空'}]}]" placeholder="请选择">
  95. <a-select-option
  96. v-for="(label,value) in trustMap"
  97. :key="value"
  98. :label="label"
  99. :value="value">{{ label }}
  100. </a-select-option>
  101. </a-select>
  102. </a-form-item>
  103. </row-item> -->
  104. <row-item>
  105. <a-form-item
  106. label="维修部门"
  107. :labelCol="BaseTool.Constant.labelCol"
  108. :wrapperCol="BaseTool.Constant.wrapperCol"
  109. >
  110. <a-select v-decorator="['repairDeptId', {rules: [{required: true, message: '维修部门不能为空'}]}]" placeholder="请选择">
  111. <a-select-option
  112. v-for="(label,value) in repairDeptMap"
  113. :key="value"
  114. :label="label"
  115. :value="value">{{ label }}
  116. </a-select-option>
  117. </a-select>
  118. </a-form-item>
  119. </row-item>
  120. <row-item>
  121. <a-form-item
  122. label="维修专业"
  123. :labelCol="BaseTool.Constant.labelCol"
  124. :wrapperCol="BaseTool.Constant.wrapperCol"
  125. >
  126. <a-tree-select
  127. tree-checkable
  128. :show-checked-strategy="SHOW_PARENT"
  129. v-decorator="['repairProfessor', { rules: [{required: true, message: '检修专业不能为空'}]}]"
  130. placeholder="请选择">
  131. <a-tree-select-node
  132. v-for="(label,value) in professorMap"
  133. :key="value"
  134. :title="label"
  135. :value="parseInt(value)">{{ label }}
  136. </a-tree-select-node>
  137. </a-tree-select>
  138. </a-form-item>
  139. </row-item>
  140. <row-item v-if="inputType===1">
  141. <a-form-item
  142. label="车间位置"
  143. :labelCol="BaseTool.Constant.labelCol"
  144. :wrapperCol="BaseTool.Constant.wrapperCol"
  145. >
  146. <a-select v-decorator="['positionId', {rules: [{required: true, message: '车间位置不能为空'}]}]" placeholder="请选择">
  147. <a-select-option
  148. v-for="({id,name}) in sbPositionData"
  149. :key="id"
  150. :label="name"
  151. :value="id">{{ name }}
  152. </a-select-option>
  153. </a-select>
  154. <!-- <a-cascader
  155. :options="sbPositionList"
  156. :load-data="loadData"
  157. placeholder="请选择"
  158. change-on-select
  159. @change="sbPositionChange"
  160. v-decorator="['sbPosition', {rules: [{required: true, message: '车间位置不能为空'}]}]"
  161. /> -->
  162. </a-form-item>
  163. </row-item>
  164. <row-item>
  165. <a-form-item
  166. label="特殊作业类型"
  167. :labelCol="BaseTool.Constant.labelCol"
  168. :wrapperCol="BaseTool.Constant.wrapperCol"
  169. >
  170. <a-tree-select
  171. tree-checkable
  172. :show-checked-strategy="SHOW_PARENT"
  173. v-decorator="['repairType', {rules: [{required: true, message: '工作类型不能为空'}]}]"
  174. placeholder="请选择">
  175. <a-tree-select-node
  176. v-for="(label,value) in repairTypeMap"
  177. :key="value"
  178. :title="label"
  179. :value="parseInt(value)">{{ label }}
  180. </a-tree-select-node>
  181. </a-tree-select>
  182. </a-form-item>
  183. </row-item>
  184. <row-item>
  185. <a-form-item
  186. label="车间具体位置"
  187. :labelCol="BaseTool.Constant.labelCol"
  188. :wrapperCol="BaseTool.Constant.wrapperCol"
  189. >
  190. <a-input
  191. placeholder="比如:甲七车间北侧"
  192. v-decorator="['sbCph']" />
  193. </a-form-item>
  194. </row-item>
  195. <row-item>
  196. <a-form-item
  197. label="工单类别"
  198. :labelCol="BaseTool.Constant.labelCol"
  199. :wrapperCol="BaseTool.Constant.wrapperCol"
  200. >
  201. <a-select @change="changePlanFlag" v-decorator="['category', {initialValue: 2, rules: [{required: true, message: '工单类别不能为空'}]}]" placeholder="请选择">
  202. <a-select-option
  203. v-for="(label,value) in categoryMap"
  204. :key="value"
  205. :label="label"
  206. :value="parseInt(value)">{{ label }}
  207. </a-select-option>
  208. </a-select>
  209. </a-form-item>
  210. </row-item>
  211. <row-item>
  212. <a-form-item
  213. label="是否停机"
  214. :labelCol="BaseTool.Constant.labelCol"
  215. :wrapperCol="BaseTool.Constant.wrapperCol"
  216. >
  217. <a-select v-decorator="['needStop', {rules: [{required: true, message: '是否停机不能为空'}]}]" placeholder="请选择">
  218. <a-select-option
  219. v-for="(label,value) in needStopMap"
  220. :key="value"
  221. :label="label"
  222. :value="parseInt(value)">{{ label }}
  223. </a-select-option>
  224. </a-select>
  225. </a-form-item>
  226. </row-item>
  227. <row-item v-if="category === 1">
  228. <a-form-item
  229. label="计划性维修级别"
  230. :labelCol="BaseTool.Constant.labelCol"
  231. :wrapperCol="BaseTool.Constant.wrapperCol"
  232. >
  233. <a-select v-decorator="['repairPlanLevel', {rules: [{required: true, message: '计划性维修级别不能为空'}]}]" placeholder="请选择">
  234. <a-select-option
  235. v-for="value in ['大','中','小']"
  236. :key="value"
  237. :label="value"
  238. :value="value">{{ value }}
  239. </a-select-option>
  240. </a-select>
  241. </a-form-item>
  242. </row-item>
  243. <row-item v-if="category === 1">
  244. <a-form-item
  245. label="审批人"
  246. :labelCol="BaseTool.Constant.labelCol"
  247. :wrapperCol="BaseTool.Constant.wrapperCol"
  248. >
  249. <a-select v-decorator="['dispatchUserId', {rules: [{required: true, message: '审批人不能为空'}]}]" placeholder="请选择">
  250. <a-select-option
  251. v-for="({realName,userId}) in dispatchUserList"
  252. :key="userId"
  253. :label="realName"
  254. :value="userId">{{ realName }}
  255. </a-select-option>
  256. </a-select>
  257. </a-form-item>
  258. </row-item>
  259. <!-- <row-item v-show="category === 1">
  260. <a-form-item
  261. label="要求日期"
  262. :labelCol="BaseTool.Constant.labelCol"
  263. :wrapperCol="BaseTool.Constant.wrapperCol"
  264. >
  265. <a-date-picker
  266. style="width: 100%"
  267. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  268. v-decorator="['limitDate']" />
  269. </a-form-item>
  270. </row-item> -->
  271. <!-- <row-item v-show="category === 2">
  272. <a-form-item
  273. label="要求时间"
  274. :labelCol="BaseTool.Constant.labelCol"
  275. :wrapperCol="BaseTool.Constant.wrapperCol"
  276. >
  277. <a-input
  278. style="width: 100%"
  279. suffix="小时"
  280. v-decorator="['limitHours', {rules: [{required: true, message: '要求时间不能为空'}]}]" />
  281. </a-form-item>
  282. </row-item> -->
  283. <row-item>
  284. <a-form-item
  285. label="计划开始时间"
  286. :labelCol="BaseTool.Constant.labelCol"
  287. :wrapperCol="BaseTool.Constant.wrapperCol"
  288. >
  289. <a-date-picker
  290. style="width: 100%"
  291. :show-time="{ format: 'HH:mm' }"
  292. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN2"
  293. v-decorator="['planStartTime', {rules: [{required: true, message: '计划开始时间不能为空'}]}]" />
  294. </a-form-item>
  295. </row-item>
  296. <row-item>
  297. <a-form-item
  298. label="计划结束时间"
  299. :labelCol="BaseTool.Constant.labelCol"
  300. :wrapperCol="BaseTool.Constant.wrapperCol"
  301. >
  302. <a-date-picker
  303. style="width: 100%"
  304. :show-time="{ format: 'HH:mm' }"
  305. :format="BaseTool.Date.PICKER_NORM_DATETIME_PATTERN2"
  306. v-decorator="['planEndTime', {rules: [{required: true, message: '计划结束时间不能为空'}]}]" />
  307. </a-form-item>
  308. </row-item>
  309. <row-item v-if="category !== 1">
  310. <a-form-item
  311. label="工作优选权"
  312. :labelCol="BaseTool.Constant.labelCol"
  313. :wrapperCol="BaseTool.Constant.wrapperCol"
  314. >
  315. <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '工作优选权不能为空'}]}]" placeholder="请选择">
  316. <a-select-option
  317. v-for="(label,value) in levelMap"
  318. :key="value"
  319. :label="label"
  320. :value="parseInt(value)">{{ label }}
  321. </a-select-option>
  322. </a-select>
  323. </a-form-item>
  324. </row-item>
  325. <row-item>
  326. <a-form-item
  327. label="报修人"
  328. :labelCol="BaseTool.Constant.labelCol"
  329. :wrapperCol="BaseTool.Constant.wrapperCol"
  330. >
  331. <a-input
  332. disabled="disabled"
  333. v-decorator="['actualUser', {initialValue: userInfo.realName, rules: [{required: true, message: '报修人不能为空'}]}]"/>
  334. </a-form-item>
  335. </row-item>
  336. <!-- <row-item>
  337. <a-form-item
  338. label="紧急等级"
  339. :labelCol="BaseTool.Constant.labelCol"
  340. :wrapperCol="BaseTool.Constant.wrapperCol"
  341. >
  342. <a-select v-decorator="['level', {initialValue: 1, rules: [{required: true, message: '紧急等级不能为空'}]}]" placeholder="请选择">
  343. <a-select-option
  344. v-for="(label,value) in levelMap"
  345. :key="value"
  346. :label="label"
  347. :value="parseInt(value)">{{ label }}
  348. </a-select-option>
  349. </a-select>
  350. </a-form-item>
  351. </row-item>
  352. <row-item>
  353. <a-form-item
  354. label="异常类别"
  355. :labelCol="BaseTool.Constant.labelCol"
  356. :wrapperCol="BaseTool.Constant.wrapperCol"
  357. >
  358. <a-tree-select
  359. style="width: 100%"
  360. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  361. :treeData="treeData"
  362. :treeNodeFilterProp="'title'"
  363. :showSearch="true"
  364. v-decorator="['repairErrorTypeId']"
  365. placeholder="请选择"
  366. >
  367. </a-tree-select>
  368. </a-form-item>
  369. </row-item>-->
  370. <row-item>
  371. <a-form-item
  372. label="报修图片"
  373. :labelCol="BaseTool.Constant.labelCol"
  374. :wrapperCol="BaseTool.Constant.wrapperCol"
  375. >
  376. <a-upload
  377. :action="uploadUrl"
  378. :multiple="true"
  379. list-type="picture"
  380. :file-list="this.defaultApplicationFileList"
  381. @change="handleApplicationFileChange"
  382. accept="image/*"
  383. :headers="headers"
  384. >
  385. <a-button> <a-icon type="upload" /> 上传图片 </a-button>
  386. </a-upload>
  387. </a-form-item>
  388. </row-item>
  389. <row-item>
  390. <a-form-item
  391. label="资料文件"
  392. :labelCol="BaseTool.Constant.labelCol"
  393. :wrapperCol="BaseTool.Constant.wrapperCol"
  394. >
  395. <a-upload
  396. :action="uploadUrl"
  397. :multiple="true"
  398. :file-list="defaultCheckFileList"
  399. @change="handleCheckFileChange"
  400. :headers="headers"
  401. >
  402. <a-button> <a-icon type="upload" /> 上传 </a-button>
  403. </a-upload>
  404. </a-form-item>
  405. </row-item>
  406. <row-item v-show="refusedFlag">
  407. <a-form-item
  408. label="驳回原因"
  409. :labelCol="BaseTool.Constant.labelCol"
  410. :wrapperCol="BaseTool.Constant.wrapperCol"
  411. >
  412. <a-input
  413. disabled="disabled"
  414. v-decorator="['remark']"/>
  415. </a-form-item>
  416. </row-item>
  417. </row-list>
  418. <row-list :col="1">
  419. <row-item v-if="false">
  420. <a-form-item
  421. label="报修状态"
  422. :labelCol="BaseTool.Constant.labelCol"
  423. :wrapperCol="BaseTool.Constant.wrapperCol"
  424. >
  425. <a-select disabled v-decorator="['status', {initialValue: DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.NOT_ALLOCATED,rules: [{required: true, message: '报修状态不能为空'}]}]" placeholder="请选择">
  426. <a-select-option
  427. v-for="(label,value) in statusMap"
  428. :key="value"
  429. :label="label"
  430. :value="parseInt(value)">{{ label }}
  431. </a-select-option>
  432. </a-select>
  433. </a-form-item>
  434. </row-item>
  435. <!-- <row-item>
  436. <a-form-item
  437. label="故障描述"
  438. :labelCol="BaseTool.Constant.labelCol2"
  439. :wrapperCol="BaseTool.Constant.wrapperCol2"
  440. >
  441. <a-select v-decorator="['content']" placeholder="请选择">
  442. <a-select-option
  443. v-for="(label,value) in questionMap"
  444. :key="value"
  445. :label="label"
  446. :value="parseInt(value)">{{ label }}
  447. </a-select-option>
  448. </a-select>
  449. </a-form-item>
  450. </row-item>-->
  451. <row-item>
  452. <a-form-item
  453. label="委托内容描述"
  454. :labelCol="BaseTool.Constant.labelCol2"
  455. :wrapperCol="BaseTool.Constant.wrapperCol2"
  456. >
  457. <a-textarea
  458. :rows="4"
  459. v-decorator="['content', {rules: [{required: true, message: '委托内容描述不能为空'}]}]"/>
  460. </a-form-item>
  461. </row-item>
  462. </row-list>
  463. </a-form>
  464. <template slot="footer">
  465. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  466. </template>
  467. <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  468. <part-info-select-modal ref="partInfoSelectModal" @selected="handlePartSelected"/>
  469. </a-modal>
  470. </template>
  471. <script>
  472. import pick from 'lodash.pick'
  473. import BaseTool from '../../../../utils/tool'
  474. import { addRepairApplicationForm, updateRepairApplicationForm, getSbPositions, getDispatchUser, receiveProfessor } from '@/api/repair/application-form'
  475. import PartInfoSelectModal from '@/views/part/info/modules/PartInfoSelectModal'
  476. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  477. import { queryUser } from '@/api/upms/user'
  478. import { uploadUrl } from '@/api/upms/file'
  479. import Vue from 'vue'
  480. import { ACCESS_TOKEN } from '@/store/mutation-types'
  481. import { fetchErrorTypeTree } from '@/api/repair/errortype'
  482. import { querySbPosition } from '@/api/sb/position'
  483. import { TreeSelect } from 'ant-design-vue'
  484. const SHOW_PARENT = TreeSelect.SHOW_PARENT
  485. export default {
  486. name: 'BaseRepairApplicationForm',
  487. data () {
  488. return {
  489. SHOW_PARENT,
  490. confirmLoading: false,
  491. modalTitle: null,
  492. inputType: 2,
  493. positionId: '',
  494. professorMap: {},
  495. repairTypeMap: {},
  496. sbPositionList: [],
  497. form: this.$form.createForm(this),
  498. visible: false,
  499. sbId: null,
  500. // 下拉框map
  501. sourceMap: {},
  502. levelMap: {},
  503. questionMap: {},
  504. dispatchUserList: {},
  505. treeData: [],
  506. sbPositionData: [],
  507. needStop: null,
  508. needStopMap: {},
  509. category: 0,
  510. categoryMap: {},
  511. trustMap: {},
  512. statusMap: {},
  513. userInfo: this.$store.getters.userInfo,
  514. userList: [],
  515. uploadUrl: uploadUrl,
  516. defaultRepairFileList: [],
  517. defaultApplicationFileList: [],
  518. defaultCheckFileList: [],
  519. applicationFileList: [], // 报修图片
  520. reportFileList: [], // 审核图片
  521. repairFileList: [], // 维修图片,
  522. repairDeptMap: {},
  523. refusedFlag: false,
  524. headers: {
  525. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  526. }
  527. }
  528. },
  529. components: {
  530. SbInfoSelectModal,
  531. PartInfoSelectModal
  532. },
  533. props: {
  534. },
  535. created () {
  536. // 下拉框map
  537. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  538. // this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  539. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  540. this.questionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_QUESTION)
  541. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  542. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.LEVEL_TYPE)
  543. this.categoryMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY)
  544. this.trustMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.TRUST_DEPT_TYPE)
  545. console.log(this.categoryMap)
  546. this.repairDeptMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_DEPT_CATEGORY)
  547. this.repairTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_TYPE)
  548. this.professorMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_PROFESSOR)
  549. this.getUsers()
  550. this.getSbPositions()
  551. querySbPosition().then(res => {
  552. this.sbPositionData = res.data
  553. })
  554. },
  555. methods: {
  556. base (record) {
  557. this.visible = true
  558. this.refusedFlag = false
  559. fetchErrorTypeTree().then(res => {
  560. this.treeData = res.data
  561. })
  562. // 如果是空标识添加
  563. if (this.BaseTool.Object.isBlank(record)) {
  564. this.modalTitle = '报修'
  565. if (!this.BaseTool.Object.isBlank(record) && !this.BaseTool.Object.isBlank(record.sbId)) {
  566. const { form: { setFieldsValue } } = this
  567. this.$nextTick(() => {
  568. setFieldsValue(Object.assign(pick(record, [
  569. 'sbId',
  570. 'sbName'
  571. ])))
  572. })
  573. }
  574. return
  575. }
  576. if (this.BaseTool.Object.isBlank(record.id)) {
  577. this.modalTitle = '报修'
  578. if (!this.BaseTool.Object.isBlank(record.sbId)) {
  579. const { form: { setFieldsValue } } = this
  580. this.$nextTick(() => {
  581. setFieldsValue(Object.assign(pick(record, [
  582. 'sbId',
  583. 'sbName',
  584. 'sbCph'
  585. ])))
  586. })
  587. }
  588. return
  589. }
  590. this.modalTitle = '编辑'
  591. this.applicationFileList = record.applicationFileList
  592. this.repairFileList = record.repairFileList
  593. this.reportFileList = record.reportFileList
  594. this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(this.applicationFileList)
  595. this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
  596. this.defaultCheckFileList = this.BaseTool.UPLOAD.transImg(this.reportFileList)
  597. if (record.status === this.DictCache.VALUE.REPAIR_APPLICATION_FORM_STATUS.REFUSED_REPAIR) {
  598. this.refusedFlag = true
  599. }
  600. const { form: { setFieldsValue } } = this
  601. // 日期处理
  602. record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  603. if (record.limitDate != null) {
  604. record.limitDate = this.BaseTool.Moment(record.limitDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  605. this.$nextTick(() => {
  606. setFieldsValue(Object.assign(pick(record, [
  607. 'limitDate'
  608. ])))
  609. })
  610. }
  611. this.$nextTick(() => {
  612. setFieldsValue(Object.assign(pick(record, [
  613. 'id',
  614. 'sbId',
  615. 'sbCph',
  616. 'partId',
  617. 'repairUserId',
  618. 'no',
  619. 'category',
  620. 'limitDate',
  621. 'limitHours',
  622. 'source',
  623. 'level',
  624. 'content',
  625. 'status',
  626. 'sbName',
  627. 'needStop',
  628. 'category',
  629. 'partName',
  630. 'remark',
  631. 'repairDeptId'
  632. ])))
  633. })
  634. },
  635. getSbPositions (parentId) {
  636. getSbPositions({ parentId }).then(res => {
  637. console.log(res)
  638. this.sbPositionList = res.data.map(item => {
  639. item = {
  640. label: item.name,
  641. value: item.name,
  642. id: item.id,
  643. isLeaf: false
  644. }
  645. return item
  646. })
  647. })
  648. },
  649. loadData (selectedOptions) {
  650. console.log(selectedOptions)
  651. const targetOption = selectedOptions[selectedOptions.length - 1]
  652. targetOption.loading = true
  653. getSbPositions({ parentId: targetOption.id }).then(res => {
  654. targetOption.loading = false
  655. targetOption.children = res.data.map(item => {
  656. item = {
  657. label: item.name,
  658. value: item.name,
  659. id: item.id
  660. }
  661. return item
  662. })
  663. this.sbPositionList = [...this.sbPositionList]
  664. })
  665. },
  666. getUsers () {
  667. queryUser({ status: 1 }).then(res => {
  668. this.userList = res.data
  669. })
  670. getDispatchUser().then(res => {
  671. console.log(res)
  672. this.dispatchUserList = res.data
  673. })
  674. },
  675. save () {
  676. const { form: { validateFieldsAndScroll } } = this
  677. this.confirmLoading = true
  678. validateFieldsAndScroll((errors, values) => {
  679. if (errors) {
  680. this.confirmLoading = false
  681. return
  682. }
  683. // 日期处理
  684. values.applyTime = this.BaseTool.Date.formatter(values.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  685. values.limitDate = BaseTool.Date.formatter(values.limitDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  686. values.planStartTime = BaseTool.Date.formatter(values.planStartTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  687. values.planEndTime = BaseTool.Date.formatter(values.planEndTime, BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  688. // 上传文件
  689. values.repairFileList = this.repairFileList
  690. values.repairProfessor = values.repairProfessor.join(',')
  691. values.repairType = values.repairType.join(',')
  692. values.applicationFileList = this.applicationFileList
  693. values.reportFileList = this.reportFileList
  694. // values.sbPosition = values.sbPosition.join('->')
  695. console.log(values)
  696. if (values.partId === undefined) {
  697. values.partId = ''
  698. }
  699. if (values.category === 2) { // 非计划性维修
  700. values.source = 2
  701. } else {
  702. values.source = 1
  703. }
  704. if (this.BaseTool.String.isBlank(values.id)) {
  705. addRepairApplicationForm(values)
  706. .then(() => {
  707. this.$notification.success({
  708. message: '报修成功!',
  709. duration: 3
  710. })
  711. this.handleCancel(values)
  712. }).catch(() => {
  713. this.confirmLoading = false
  714. })
  715. } else {
  716. updateRepairApplicationForm(values)
  717. .then(() => {
  718. this.handleCancel(values)
  719. }).catch(() => {
  720. this.confirmLoading = false
  721. })
  722. }
  723. })
  724. },
  725. changePlanFlag (value) {
  726. this.category = value
  727. const { form: { setFieldsValue } } = this
  728. if (this.category === 1) {
  729. this.$nextTick(() => {
  730. setFieldsValue({ needStop: 1 })
  731. })
  732. } else {
  733. this.$nextTick(() => {
  734. setFieldsValue({ needStop: 0 })
  735. })
  736. }
  737. },
  738. handleCancel (values) {
  739. this.visible = false
  740. this.confirmLoading = false
  741. this.applicationFileList = []
  742. this.defaultApplicationFileList = []
  743. this.form.resetFields()
  744. if (this.BaseTool.Object.isNotBlank(values)) {
  745. this.$emit('ok', values)
  746. }
  747. },
  748. handleSbSelect () {
  749. this.$refs.sbInfoSelectModal.base({}, {})
  750. },
  751. handleSbSelectd (keys, rows) {
  752. const [ key ] = keys
  753. const [ row ] = rows
  754. const { form: { setFieldsValue } } = this
  755. this.sbId = key
  756. // 日期处理
  757. receiveProfessor({ id: key }).then(res => {
  758. const val = res.data ? res.data : 1
  759. this.$nextTick(() => {
  760. setFieldsValue(Object.assign({
  761. 'sbId': key,
  762. 'sbName': row.name,
  763. 'sbCph': row.cph,
  764. 'repairProfessor': [val]
  765. // 'parentSbNo': row.ppNo
  766. }))
  767. })
  768. })
  769. },
  770. handlePartSelect () {
  771. if (this.sbId === null) {
  772. return this.$message.error('选择设备部位之前,请选择设备')
  773. }
  774. this.$refs.partInfoSelectModal.base({ sbId: this.sbId })
  775. },
  776. handlePartSelected (keys, rows) {
  777. const [ key ] = keys
  778. const [ row ] = rows
  779. const { form: { setFieldsValue } } = this
  780. this.$nextTick(() => {
  781. setFieldsValue(Object.assign({
  782. 'partId': key,
  783. 'partName': row.name
  784. }))
  785. })
  786. },
  787. handleCheckFileChange (info) {
  788. this.defaultCheckFileList = info.fileList
  789. this.reportFileList = this.setFileList(info, 32)
  790. },
  791. handleApplicationFileChange (info) {
  792. this.defaultApplicationFileList = info.fileList
  793. this.applicationFileList = this.setFileList(info, 11)
  794. },
  795. setFileList (info, type) {
  796. const file = info.file
  797. const fileList = info.fileList
  798. if (file.status === 'done') {
  799. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  800. } else if (file.status === 'removed') {
  801. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  802. } else if (file.status === 'error') {
  803. this.$message.error('上传失败')
  804. return []
  805. }
  806. },
  807. inputTypeChange (e) {
  808. this.inputType = e.target.value
  809. this.form.resetFields()
  810. },
  811. sbPositionChange (e, val) {
  812. this.positionId = val[val.length - 1].id
  813. }
  814. }
  815. }
  816. </script>