BaseForm.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
  3. <a-row :gutter="48" slot="extra">
  4. <a-col :md="48" :sm="48">
  5. <span class="table-page-search-submitButtons" style="float: right">
  6. <a-button type="primary" @click="save()">提交</a-button>
  7. <a-button style="margin-left: 8px" @click="handleCancel()">返回</a-button>
  8. </span>
  9. </a-col>
  10. </a-row>
  11. <title-divider title="基本信息" width="90px"></title-divider>
  12. <a-form :form="form">
  13. <a-form-item v-show="false" >
  14. <a-input v-decorator="['id']" type="hidden"/>
  15. <a-input v-decorator="['parentId']" type="hidden"/>
  16. </a-form-item>
  17. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  18. <a-col :lg="12" :md="24" :sm="24">
  19. <a-form-item
  20. label="测量设备编号"
  21. :labelCol="BaseTool.Constant.labelCol"
  22. :wrapperCol="BaseTool.Constant.wrapperCol"
  23. >
  24. <a-input
  25. v-decorator="['cardNo', {rules: [{required: true, message: '不能为空'}]}]" />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :lg="12" :md="24" :sm="24">
  29. <a-form-item
  30. label="设备(新号)"
  31. :labelCol="BaseTool.Constant.labelCol"
  32. :wrapperCol="BaseTool.Constant.wrapperCol"
  33. >
  34. <a-input
  35. v-decorator="['no', {rules: [{required: false, message: '不能为空'}]}]" />
  36. </a-form-item>
  37. </a-col>
  38. <a-col :lg="12" :md="24" :sm="24">
  39. <a-form-item
  40. label="设备名称"
  41. :labelCol="BaseTool.Constant.labelCol"
  42. :wrapperCol="BaseTool.Constant.wrapperCol"
  43. >
  44. <a-input
  45. v-decorator="['name', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  46. </a-form-item>
  47. </a-col>
  48. <a-col :lg="12" :md="24" :sm="24">
  49. <a-form-item
  50. label="型号"
  51. :labelCol="BaseTool.Constant.labelCol"
  52. :wrapperCol="BaseTool.Constant.wrapperCol"
  53. >
  54. <a-input
  55. v-decorator="['model', {rules: [{required: false, message: '设备型号不能为空'}]}]" />
  56. </a-form-item>
  57. </a-col>
  58. <a-col :lg="12" :md="24" :sm="24">
  59. <a-form-item
  60. label="出厂编号"
  61. :labelCol="BaseTool.Constant.labelCol"
  62. :wrapperCol="BaseTool.Constant.wrapperCol"
  63. >
  64. <a-input
  65. v-decorator="['zzh']" />
  66. </a-form-item>
  67. </a-col>
  68. <a-col :lg="12" :md="24" :sm="24">
  69. <a-form-item
  70. label="要求准确度等级"
  71. :labelCol="BaseTool.Constant.labelCol"
  72. :wrapperCol="BaseTool.Constant.wrapperCol"
  73. >
  74. <a-input
  75. v-decorator="['zz']" />
  76. </a-form-item>
  77. </a-col>
  78. <a-col :lg="12" :md="24" :sm="24">
  79. <a-form-item
  80. label="使用部门"
  81. :labelCol="BaseTool.Constant.labelCol"
  82. :wrapperCol="BaseTool.Constant.wrapperCol"
  83. >
  84. <a-input
  85. v-decorator="['useDept']" />
  86. </a-form-item>
  87. </a-col>
  88. <a-col :lg="12" :md="24" :sm="24">
  89. <a-form-item
  90. label="使用地点"
  91. :labelCol="BaseTool.Constant.labelCol"
  92. :wrapperCol="BaseTool.Constant.wrapperCol"
  93. >
  94. <a-input
  95. v-decorator="['cph']" />
  96. </a-form-item>
  97. </a-col>
  98. <a-col :lg="12" :md="24" :sm="24">
  99. <a-form-item
  100. label="生产商"
  101. :labelCol="BaseTool.Constant.labelCol"
  102. :wrapperCol="BaseTool.Constant.wrapperCol"
  103. >
  104. <a-input
  105. v-decorator="['producerId']" />
  106. </a-form-item>
  107. </a-col>
  108. <a-col :lg="12" :md="24" :sm="24">
  109. <a-form-item
  110. label="管理状态"
  111. :labelCol="BaseTool.Constant.labelCol"
  112. :wrapperCol="BaseTool.Constant.wrapperCol"
  113. >
  114. <a-select v-decorator="['status', {rules: [{required: true, message: '状态不能为空'}]}]" placeholder="请选择">
  115. <a-select-option
  116. v-for="(label,value) in statusMap"
  117. :key="value"
  118. :label="label"
  119. :value="parseInt(value)">{{ label }}
  120. </a-select-option>
  121. </a-select>
  122. </a-form-item>
  123. </a-col>
  124. <a-col :lg="12" :md="24" :sm="24">
  125. <a-form-item
  126. label="是否固定资产"
  127. :labelCol="BaseTool.Constant.labelCol"
  128. :wrapperCol="BaseTool.Constant.wrapperCol"
  129. >
  130. <a-select v-decorator="['isFinancing', { rules: [{required: true, message: '是否显示不能为空'}]}]" placeholder="请选择">
  131. <a-select-option
  132. v-for="(label,value) in isFinancingMap"
  133. :key="value"
  134. :label="label"
  135. :value="parseInt(value)">{{ label }}
  136. </a-select-option>
  137. </a-select>
  138. </a-form-item>
  139. </a-col>
  140. <a-col :lg="12" :md="24" :sm="24">
  141. <a-form-item
  142. label="固定资产编号"
  143. :labelCol="BaseTool.Constant.labelCol"
  144. :wrapperCol="BaseTool.Constant.wrapperCol"
  145. >
  146. <a-input
  147. v-decorator="['financingNo']" />
  148. </a-form-item>
  149. </a-col>
  150. <a-col :lg="12" :md="24" :sm="24">
  151. <a-form-item
  152. label="准确度等级"
  153. :labelCol="BaseTool.Constant.labelCol"
  154. :wrapperCol="BaseTool.Constant.wrapperCol"
  155. >
  156. <a-input
  157. v-decorator="['fdjxh']" />
  158. </a-form-item>
  159. </a-col>
  160. <a-col :lg="12" :md="24" :sm="24">
  161. <a-form-item
  162. label="检定单位"
  163. :labelCol="BaseTool.Constant.labelCol"
  164. :wrapperCol="BaseTool.Constant.wrapperCol"
  165. >
  166. <a-input
  167. v-decorator="['dph']" />
  168. </a-form-item>
  169. </a-col>
  170. <a-col :lg="12" :md="24" :sm="24">
  171. <a-form-item
  172. label="检定人"
  173. :labelCol="BaseTool.Constant.labelCol"
  174. :wrapperCol="BaseTool.Constant.wrapperCol"
  175. >
  176. <a-input
  177. v-decorator="['zaiz']" />
  178. </a-form-item>
  179. </a-col>
  180. <a-col :lg="12" :md="24" :sm="24">
  181. <a-form-item
  182. label="检定结论"
  183. :labelCol="BaseTool.Constant.labelCol"
  184. :wrapperCol="BaseTool.Constant.wrapperCol"
  185. >
  186. <a-select v-decorator="['rlType']" placeholder="请选择">
  187. <a-select-option
  188. v-for="(label,value) in measureMap"
  189. :key="value"
  190. :label="label"
  191. :value="parseInt(value)">{{ label }}
  192. </a-select-option>
  193. </a-select>
  194. </a-form-item>
  195. </a-col>
  196. <a-col :lg="12" :md="24" :sm="24">
  197. <a-form-item
  198. label="是否周检查"
  199. :labelCol="BaseTool.Constant.labelCol"
  200. :wrapperCol="BaseTool.Constant.wrapperCol"
  201. >
  202. <a-select v-decorator="['color']" placeholder="请选择">
  203. <a-select-option
  204. key="0"
  205. label="否"
  206. value="0">否
  207. </a-select-option>
  208. <a-select-option
  209. key="1"
  210. label="是"
  211. value="1">是
  212. </a-select-option>
  213. </a-select>
  214. </a-form-item>
  215. </a-col>
  216. <a-col :lg="12" :md="24" :sm="24">
  217. <a-form-item
  218. label="检定证书编号"
  219. :labelCol="BaseTool.Constant.labelCol"
  220. :wrapperCol="BaseTool.Constant.wrapperCol"
  221. >
  222. <a-input
  223. v-decorator="['sbdh']" />
  224. </a-form-item>
  225. </a-col>
  226. <a-col :lg="12" :md="24" :sm="24">
  227. <a-form-item
  228. label="预警天数"
  229. :labelCol="BaseTool.Constant.labelCol"
  230. :wrapperCol="BaseTool.Constant.wrapperCol"
  231. >
  232. <a-input-number
  233. style="width: 100%"
  234. :min="0"
  235. :step="0.01"
  236. :formatter="BaseTool.Amount.formatter"
  237. :parser="BaseTool.Amount.parser"
  238. v-decorator="['seatNumber']" />
  239. </a-form-item>
  240. </a-col>
  241. <a-col :lg="12" :md="24" :sm="24">
  242. <a-form-item
  243. label="检定日期"
  244. :labelCol="BaseTool.Constant.labelCol"
  245. :wrapperCol="BaseTool.Constant.wrapperCol"
  246. >
  247. <a-date-picker
  248. style="width: 100%"
  249. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  250. v-decorator="['checkDate']" />
  251. </a-form-item>
  252. </a-col>
  253. <a-col :lg="12" :md="24" :sm="24">
  254. <a-form-item
  255. label="检定周期"
  256. :labelCol="BaseTool.Constant.labelCol"
  257. :wrapperCol="BaseTool.Constant.wrapperCol"
  258. >
  259. <a-input
  260. style="width: 100%"
  261. suffix="月"
  262. :formatter="BaseTool.Amount.formatter"
  263. :parser="BaseTool.Amount.parser"
  264. v-decorator="['checkPeriod']" />
  265. </a-form-item>
  266. </a-col>
  267. <a-col :lg="12" :md="24" :sm="24">
  268. <a-form-item
  269. label="检定有效期"
  270. :labelCol="BaseTool.Constant.labelCol"
  271. :wrapperCol="BaseTool.Constant.wrapperCol"
  272. >
  273. <a-date-picker
  274. style="width: 100%"
  275. disabled
  276. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  277. v-decorator="['nextCheckDate']" />
  278. </a-form-item>
  279. </a-col>
  280. <a-col :lg="12" :md="24" :sm="24">
  281. <a-form-item
  282. label="检定校准记录"
  283. :labelCol="BaseTool.Constant.labelCol"
  284. :wrapperCol="BaseTool.Constant.wrapperCol"
  285. >
  286. <a-input
  287. v-decorator="['zbh']" />
  288. </a-form-item>
  289. </a-col>
  290. <a-col :lg="12" :md="24" :sm="24">
  291. <a-form-item
  292. label="备注"
  293. :labelCol="BaseTool.Constant.labelCol"
  294. :wrapperCol="BaseTool.Constant.wrapperCol"
  295. >
  296. <a-input
  297. v-decorator="['remark']" />
  298. </a-form-item>
  299. </a-col>
  300. </a-row>
  301. </a-form>
  302. <sb-model-select-modal ref="sbModelSelectModal" @selected="handleSbModelSelected"/>
  303. <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  304. <firm-producer-select-modal ref="producerSelectModal" @selected="handleProducerSelected"/>
  305. </a-card>
  306. </template>
  307. <script>
  308. import pick from 'lodash.pick'
  309. import { addSbInfo, updateSbInfo, fetchSbInfo, copySbInfo } from '@/api/sb/measure'
  310. import { fetchSbTypeTree } from '@/api/sb/type'
  311. import { querySbPosition } from '@/api/sb/position'
  312. import FirmProducerSelectModal from '@/views/firm/producer/modules/FirmProducerSelectModal'
  313. import SbGuigeSelectModal from '@/views/sb/guige/modules/SbGuigeSelectModal'
  314. import SbModelSelectModal from '@/views/sb/model/modules/SbModelSelectModal'
  315. import BaseTool from '../../../../utils/tool'
  316. import { queryUserDeptByUserDeptId } from '@/api/upms/user-dept'
  317. import { ACCESS_TOKEN } from '@/store/mutation-types'
  318. import Vue from 'vue'
  319. import { uploadUrl } from '@/api/upms/file'
  320. import { queryDept, getDeptsAllByParentId } from '@/api/upms/dept'
  321. import { queryUser } from '@/api/upms/user'
  322. import DetailList from '@/components/tools/DetailList'
  323. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  324. const DetailListItem = DetailList.Item
  325. export default {
  326. name: 'BaseSbInfo',
  327. components: {
  328. FirmProducerSelectModal,
  329. SbGuigeSelectModal,
  330. SbModelSelectModal,
  331. SbInfoSelectModal,
  332. DetailList,
  333. DetailListItem
  334. },
  335. data () {
  336. return {
  337. confirmLoading: false,
  338. modalTitle: null,
  339. form: this.$form.createForm(this),
  340. areaList: {},
  341. companyList: {},
  342. paramList: [],
  343. projectList: {},
  344. deptList: {},
  345. groupList: {},
  346. visible: false,
  347. sbTypeTreeData: [],
  348. sbPositionData: [],
  349. measureMap: {},
  350. statusMap: {},
  351. isFinancingMap: {},
  352. userList: {},
  353. sbInfoSelectType: null,
  354. repairFileList: [], // 维修手册
  355. defaultRepairFileList: [],
  356. defaultUseFileList: [],
  357. defaultRecheckFileList: [],
  358. defaultSbFileList: [],
  359. useFileList: [], // 使用手册
  360. recheckFileList: [], // 验收手册
  361. sbFileList: [], // 设备图片,
  362. uploadUrl: uploadUrl,
  363. qrcodesrc: null,
  364. id: null,
  365. fileList: [],
  366. type: null,
  367. headers: {
  368. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  369. }
  370. }
  371. },
  372. created () {
  373. this.measureMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MEASURE_RESULT)
  374. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_MEASURE_STATUS)
  375. this.isFinancingMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_IS_FINANCING)
  376. },
  377. methods: {
  378. base (record, type) {
  379. this.setTree(record)
  380. // 清除文件列表
  381. this.visible = true
  382. // 选择框查询条件
  383. // 如果是空标识添加
  384. if (this.BaseTool.Object.isBlank(record)) {
  385. this.qrcodesrc = null
  386. this.modalTitle = '添加'
  387. this.clearFileList()
  388. return
  389. }
  390. this.modalTitle = '编辑'
  391. this.id = record.id
  392. this.qrcodesrc = record.qrCode
  393. this.repairFileList = record.repairFileList
  394. this.useFileList = record.useFileList
  395. this.recheckFileList = record.recheckFileList
  396. this.sbFileList = record.sbFileList
  397. this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
  398. this.defaultUseFileList = this.BaseTool.UPLOAD.transImg(this.useFileList)
  399. this.defaultRecheckFileList = this.BaseTool.UPLOAD.transImg(this.recheckFileList)
  400. this.defaultSbFileList = this.BaseTool.UPLOAD.transImg(this.sbFileList)
  401. this.paramList = JSON.parse(record.paramList)
  402. if (type === 1) {
  403. this.type = type
  404. this.modalTitle = '复制'
  405. this.qrcodesrc = null
  406. record.no = null
  407. this.clearFileList()
  408. }
  409. const { form: { setFieldsValue } } = this
  410. // 日期处理
  411. // record.buyDate = this.BaseTool.Moment(record.buyDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  412. // record.startDate = this.BaseTool.Moment(record.startDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  413. // record.nextCheckDate = this.BaseTool.Moment(record.nextCheckDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  414. // record.guaranteeDate = this.BaseTool.Moment(record.guaranteeDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  415. // record.retirementDate = this.BaseTool.Moment(record.retirementDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  416. // record.lastRepaireTime = this.BaseTool.Moment(record.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  417. // record.lastBaoyangTime = this.BaseTool.Moment(record.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  418. if (record.buyDate != null) {
  419. record.buyDate = this.BaseTool.Moment(record.buyDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  420. this.$nextTick(() => {
  421. setFieldsValue(Object.assign(pick(record, [
  422. 'buyDate'
  423. ])))
  424. })
  425. }
  426. if (record.startDate != null) {
  427. record.startDate = this.BaseTool.Moment(record.startDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  428. this.$nextTick(() => {
  429. setFieldsValue(Object.assign(pick(record, [
  430. 'startDate'
  431. ])))
  432. })
  433. }
  434. if (record.checkDate != null) {
  435. record.checkDate = this.BaseTool.Moment(record.checkDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  436. this.$nextTick(() => {
  437. setFieldsValue(Object.assign(pick(record, [
  438. 'checkDate'
  439. ])))
  440. })
  441. }
  442. if (record.nextCheckDate != null) {
  443. record.nextCheckDate = this.BaseTool.Moment(record.nextCheckDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  444. this.$nextTick(() => {
  445. setFieldsValue(Object.assign(pick(record, [
  446. 'nextCheckDate'
  447. ])))
  448. })
  449. }
  450. if (record.retirementDate != null) {
  451. record.retirementDate = this.BaseTool.Moment(record.retirementDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  452. this.$nextTick(() => {
  453. setFieldsValue(Object.assign(pick(record, [
  454. 'retirementDate'
  455. ])))
  456. })
  457. }
  458. if (record.registerDate != null) {
  459. record.registerDate = this.BaseTool.Moment(record.registerDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  460. this.$nextTick(() => {
  461. setFieldsValue(Object.assign(pick(record, [
  462. 'registerDate'
  463. ])))
  464. })
  465. }
  466. record.unitName = this.BaseTool.Object.getField(this.unitMap, record.unit)
  467. this.$nextTick(() => {
  468. setFieldsValue(Object.assign(pick(record, [
  469. 'id',
  470. 'no',
  471. 'parentId',
  472. 'parentSbName',
  473. 'zz',
  474. 'zbh',
  475. 'isChild',
  476. 'isShow',
  477. 'isFinancing',
  478. 'financingNo',
  479. 'financingNoTwo',
  480. 'financingNoThird',
  481. 'financingNoFour',
  482. 'financingNoFive',
  483. 'name',
  484. 'model',
  485. 'cph',
  486. 'positionId',
  487. 'producerName',
  488. 'useArea',
  489. 'useCompany',
  490. 'useProject',
  491. 'useDept',
  492. 'saveUser',
  493. 'repairUser',
  494. 'useGroup',
  495. 'typeId',
  496. 'level',
  497. 'initialValue',
  498. // 'cutValue',
  499. 'producerId',
  500. // 'sourceType',
  501. 'unit',
  502. 'buyDate',
  503. 'startDate',
  504. 'zbh',
  505. // 'wbFile',
  506. // 'useFile',
  507. // 'checkFile',
  508. // 'sbImage',
  509. 'status',
  510. 'remark',
  511. 'zzh',
  512. 'zz',
  513. 'zjm',
  514. 'jbdh',
  515. 'useType',
  516. 'cardNo',
  517. 'fdjxh',
  518. 'checkDate',
  519. 'checkPeriod',
  520. 'nextCheckDate',
  521. 'dph',
  522. 'zaiz',
  523. 'rlType',
  524. 'color',
  525. 'sbdh',
  526. 'seatNumber',
  527. 'registerNo',
  528. 'characterType',
  529. 'usedNo',
  530. 'supplier',
  531. 'repairUserSecond',
  532. 'batchNo',
  533. 'workYear',
  534. 'retirementDate',
  535. 'registerDate'
  536. ])))
  537. })
  538. },
  539. save () {
  540. const { form: { validateFieldsAndScroll } } = this
  541. this.confirmLoading = true
  542. validateFieldsAndScroll((errors, values) => {
  543. if (errors) {
  544. this.confirmLoading = false
  545. return
  546. }
  547. // 日期数据的处理
  548. values.buyDate = BaseTool.Date.formatter(values.buyDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  549. values.startDate = BaseTool.Date.formatter(values.startDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  550. values.checkDate = BaseTool.Date.formatter(values.checkDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  551. values.nextCheckDate = BaseTool.Date.formatter(values.nextCheckDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  552. values.guaranteeDate = BaseTool.Date.formatter(values.guaranteeDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  553. values.retirementDate = BaseTool.Date.formatter(values.retirementDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  554. values.lastRepaireTime = this.BaseTool.Date.formatter(values.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  555. values.lastBaoyangTime = this.BaseTool.Date.formatter(values.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  556. values.spDate = this.BaseTool.Date.formatter(values.spDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  557. values.jbdDate = this.BaseTool.Date.formatter(values.jbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  558. values.sbdDate = this.BaseTool.Date.formatter(values.sbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  559. values.sbDate = this.BaseTool.Date.formatter(values.sbDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  560. // 上传文件
  561. values.repairFileList = this.repairFileList
  562. values.useFileList = this.useFileList
  563. values.recheckFileList = this.recheckFileList
  564. values.sbFileList = this.sbFileList
  565. values.paramList = JSON.stringify(this.paramList)
  566. if (this.BaseTool.String.isBlank(values.id)) {
  567. addSbInfo(values)
  568. .then(() => {
  569. this.handleCancel(values)
  570. }).catch(() => {
  571. this.confirmLoading = false
  572. })
  573. } else {
  574. if (this.type == null) {
  575. updateSbInfo(values)
  576. .then(() => {
  577. this.handleCancel(values)
  578. }).catch(() => {
  579. this.confirmLoading = false
  580. })
  581. } else {
  582. copySbInfo(values)
  583. .then(() => {
  584. this.handleCancel(values)
  585. }).catch(() => {
  586. this.confirmLoading = false
  587. })
  588. }
  589. }
  590. })
  591. },
  592. getQrcodeSrc () {
  593. console.log(111, 22)
  594. },
  595. handleCancel () {
  596. this.visible = false
  597. this.confirmLoading = false
  598. this.form.resetFields()
  599. this.$emit('ok')
  600. },
  601. handleFresh () {
  602. fetchSbInfo({ id: this.id }).then(res => {
  603. const { form: { setFieldsValue } } = this
  604. const record = res.data
  605. this.$nextTick(() => {
  606. setFieldsValue(Object.assign(pick(record, [
  607. 'zjm',
  608. 'jbdh'
  609. ])))
  610. })
  611. })
  612. },
  613. setTree (record = {}) {
  614. fetchSbTypeTree().then(res => {
  615. this.sbTypeTreeData = res.data
  616. })
  617. querySbPosition().then(res => {
  618. this.sbPositionData = res.data
  619. })
  620. // getSbInfoTree({ id: record.id }).then(res => {
  621. // this.sbInfoTreeData = res.data
  622. // this.sourceSbInfoTreeData = res.data
  623. // })
  624. // getSbPositionTree().then(res => {
  625. // this.sbPositionTreeData = res.data
  626. // })
  627. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  628. this.areaList = res.data
  629. })
  630. if (record.useArea != null) {
  631. getDeptsAllByParentId({ deptId: record.useArea, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  632. this.companyList = res.data
  633. })
  634. getDeptsAllByParentId({ deptId: record.useCompany, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU }).then(res => {
  635. this.projectList = res.data
  636. })
  637. getDeptsAllByParentId({ deptId: record.useProject, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BU_MEN }).then(res => {
  638. this.deptList = res.data
  639. })
  640. getDeptsAllByParentId({ deptId: record.useDept, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BAN_ZU }).then(res => {
  641. this.groupList = res.data
  642. })
  643. queryUser({ }).then(res => {
  644. this.userList = res.data
  645. })
  646. }
  647. queryUser({ }).then(res => {
  648. this.userList = res.data
  649. })
  650. },
  651. handleSbModelSelect () {
  652. const modal = this.$refs.sbModelSelectModal
  653. modal.base()
  654. },
  655. handleSbModelSelected (keys, rows) {
  656. const [ key ] = keys
  657. const [ row ] = rows
  658. const { form: { setFieldsValue } } = this
  659. this.$nextTick(() => {
  660. setFieldsValue({
  661. 'modelId': key,
  662. 'name': row.name,
  663. 'model': row.model,
  664. 'nameModel': row.nameModel,
  665. 'typeId': row.typeId,
  666. 'typeName': row.typeName,
  667. 'level': row.level,
  668. 'initialValue': row.value,
  669. 'useType': row.useType,
  670. 'useTypeName': this.BaseTool.Object.getField(this.useTypeMap, row.useType),
  671. 'producerId': row.producerId,
  672. 'producerName': row.producerName,
  673. 'unit': row.unit,
  674. 'unitName': this.BaseTool.Object.getField(this.unitMap, row.unit)
  675. })
  676. })
  677. },
  678. beforeRecheckFileListUpload (file) {
  679. const reg = /\.(xls|xlsx)(\?.*)?$/
  680. return new Promise((resolve, reject) => {
  681. if (reg.test(file.name)) {
  682. this.recheckFileList = [file]
  683. return true
  684. } else {
  685. this.$message.error(`请上传正确的xls|xlsx文件`)
  686. reject(new Error('请上传正确的xls|xlsx文件'))
  687. return false
  688. }
  689. })
  690. },
  691. beforeUploadPic (file) {
  692. const reg = /\.(jpg|jpeg|png)(\?.*)?$/
  693. return new Promise((resolve, reject) => {
  694. if (reg.test(file.name)) {
  695. this.sbFileList = [file]
  696. return true
  697. } else {
  698. this.$message.error(`请上传正确的jpg|jpeg|png文件`)
  699. reject(new Error('请上传正确的jpg|jpeg|png文件'))
  700. return false
  701. }
  702. })
  703. },
  704. clearFileList () {
  705. this.repairFileList = []
  706. this.useFileList = []
  707. this.recheckFileList = []
  708. this.sbFileList = []
  709. },
  710. handleRepairFileChange (info) {
  711. this.defaultRepairFileList = info.fileList
  712. this.repairFileList = this.setFileList(info, 1)
  713. },
  714. handleUseFileChange (info) {
  715. this.defaultUseFileList = info.fileList
  716. this.useFileList = this.setFileList(info, 2)
  717. },
  718. handleAreaChange (value) {
  719. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  720. this.companyList = res.data
  721. })
  722. },
  723. handleCompanyChange (value) {
  724. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU }).then(res => {
  725. this.projectList = res.data
  726. })
  727. },
  728. handleProjectChange (value) {
  729. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BU_MEN }).then(res => {
  730. this.deptList = res.data
  731. })
  732. },
  733. handleDeptChange (value) {
  734. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BAN_ZU }).then(res => {
  735. this.groupList = res.data
  736. })
  737. },
  738. handleGroupChange (value) {
  739. queryUserDeptByUserDeptId({ deptId: value }).then(res => {
  740. this.userList = res.data
  741. })
  742. },
  743. handleRecheckFileChange (info) {
  744. this.defaultRecheckFileList = info.fileList
  745. this.recheckFileList = this.setFileList(info, 3)
  746. },
  747. handleSbFileChange (info) {
  748. this.defaultSbFileList = info.fileList
  749. this.sbFileList = this.setFileList(info, 4)
  750. },
  751. setFileList1 (info, type) {
  752. const fileList = [...info.fileList]
  753. const file = [...info.file]
  754. if (file.status === 'done') {
  755. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  756. } else if (file.status === 'removed') {
  757. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  758. } else if (file.status === 'error') {
  759. this.$message.error('上传失败')
  760. return []
  761. }
  762. },
  763. clearParent () {
  764. const { form: { setFieldsValue } } = this
  765. // 日期处理
  766. this.$nextTick(() => {
  767. setFieldsValue(Object.assign({
  768. 'parentId': null,
  769. 'parentSbName': null
  770. }))
  771. })
  772. },
  773. // 主子设备切换
  774. childChange (value) {
  775. if (value === this.DictCache.VALUE.SB_IS_CHILD.IS_PARENT || value === this.DictCache.VALUE.SB_IS_CHILD.IS_NORMAL) {
  776. const { form: { setFieldsValue } } = this
  777. // 日期处理
  778. this.$nextTick(() => {
  779. setFieldsValue(Object.assign({
  780. 'parentId': null,
  781. 'parentSbName': null
  782. }))
  783. })
  784. }
  785. },
  786. handleSbSelect () {
  787. this.$refs.sbInfoSelectModal.base({}, { isChild: this.DictCache.VALUE.SB_IS_CHILD.IS_PARENT })
  788. },
  789. handleSbSelectd (keys, rows) {
  790. const [ key ] = keys
  791. const [ row ] = rows
  792. const { form: { setFieldsValue } } = this
  793. // 日期处理
  794. this.$nextTick(() => {
  795. setFieldsValue(Object.assign({
  796. 'parentId': key,
  797. 'parentSbName': row.name,
  798. 'isChild': this.DictCache.VALUE.SB_IS_CHILD.IS_CHILD
  799. }))
  800. })
  801. },
  802. handleChange (value) {
  803. },
  804. handleProducerSelect () {
  805. const modal = this.$refs.producerSelectModal
  806. modal.base({}, { type: 1 })
  807. },
  808. handleProducerSelected (record, selectedRowKeys, selectedRow) {
  809. const { form: { setFieldsValue } } = this
  810. const [ key ] = selectedRowKeys
  811. const [ row ] = selectedRow
  812. setFieldsValue({
  813. 'producerId': key,
  814. 'producerName': row.name
  815. })
  816. },
  817. filterOptionProducer (input, option) {
  818. return (
  819. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  820. )
  821. },
  822. setFileList (info, type) {
  823. // { file, fileList }
  824. const file = info.file
  825. const fileList = info.fileList
  826. // fileList = fileList.slice(-2)
  827. // console.log(111, this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type))
  828. if (file.status === 'done') {
  829. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  830. } else if (file.status === 'removed') {
  831. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  832. } else if (file.status === 'error') {
  833. this.$message.error('上传失败')
  834. return null
  835. }
  836. },
  837. handlePoint () {
  838. const { form: { getFieldValue } } = this
  839. const zjm = getFieldValue('zjm')
  840. const jbdh = getFieldValue('jbdh')
  841. const a = document.createElement('a')
  842. a.href = '/hitch-screen/point.html?id=' + this.id + '&zjm=' + zjm + '&jbdh=' + jbdh
  843. a.target = '_blank'
  844. a.click()
  845. },
  846. handleParam () {
  847. const modal = this.$refs.paramForm
  848. modal.base(this.model)
  849. },
  850. handleParamList (values) {
  851. console.log(values)
  852. if (this.paramList == null) {
  853. this.paramList = []
  854. }
  855. this.paramList.push(values)
  856. },
  857. handleDelParam (index) {
  858. console.log(index)
  859. this.paramList.splice(index, 1)
  860. }
  861. }
  862. }
  863. </script>