BaseForm.vue 31 KB

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