BaseForm.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001
  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="['no', {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="['zbh', {rules: [{required: false, message: '不能为空'}]}]" />
  36. </a-form-item>
  37. </a-col>
  38. </a-row>
  39. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  40. <a-col :lg="12" :md="24" :sm="24">
  41. <a-form-item
  42. label="设备名称"
  43. :labelCol="BaseTool.Constant.labelCol"
  44. :wrapperCol="BaseTool.Constant.wrapperCol"
  45. >
  46. <a-input
  47. v-decorator="['name', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  48. </a-form-item>
  49. </a-col>
  50. <a-col :lg="12" :md="24" :sm="24">
  51. <a-form-item
  52. label="型号"
  53. :labelCol="BaseTool.Constant.labelCol"
  54. :wrapperCol="BaseTool.Constant.wrapperCol"
  55. >
  56. <a-input
  57. v-decorator="['model', {rules: [{required: true, message: '设备型号不能为空'}]}]" />
  58. </a-form-item>
  59. </a-col>
  60. </a-row>
  61. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  62. <a-col :lg="12" :md="24" :sm="24">
  63. <a-form-item
  64. label="设备等级"
  65. :labelCol="BaseTool.Constant.labelCol"
  66. :wrapperCol="BaseTool.Constant.wrapperCol"
  67. >
  68. <a-select v-decorator="['level', {initialValue:1, rules: [{required: true, message: '设备等级不能为空'}]}]" placeholder="请选择">
  69. <a-select-option
  70. v-for="(label,value) in levelMap"
  71. :key="value"
  72. :label="label"
  73. :value="parseInt(value)">{{ label }}
  74. </a-select-option>
  75. </a-select>
  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-number
  85. style="width: 100%"
  86. :min="0"
  87. :step="0.01"
  88. :formatter="BaseTool.Amount.formatter"
  89. :parser="BaseTool.Amount.parser"
  90. v-decorator="['initialValue', {rules: [{required: true, message: '设备原值不能为空'}]}]" />
  91. </a-form-item>
  92. </a-col>
  93. </a-row>
  94. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  95. <a-col :lg="12" :md="24" :sm="24">
  96. <a-form-item
  97. label="设备类型"
  98. :labelCol="BaseTool.Constant.labelCol"
  99. :wrapperCol="BaseTool.Constant.wrapperCol"
  100. >
  101. <a-tree-select
  102. style="width: 100%"
  103. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  104. :treeData="sbTypeTreeData"
  105. :treeNodeFilterProp="'title'"
  106. :showSearch="true"
  107. v-decorator="['typeId', {rules: [{required: true, message: '设备类型不能为空'}]}]"
  108. placeholder="请选择"
  109. >
  110. </a-tree-select>
  111. </a-form-item>
  112. </a-col>
  113. <a-col :lg="12" :md="24" :sm="24">
  114. <a-form-item
  115. label="自定义类型"
  116. :labelCol="BaseTool.Constant.labelCol"
  117. :wrapperCol="BaseTool.Constant.wrapperCol"
  118. >
  119. <a-select v-decorator="['useType', {rules: [{required: true, message: '自定义类型不能为空'}]}]" placeholder="请选择">
  120. <a-select-option
  121. v-for="(label,value) in useTypeMap"
  122. :key="value"
  123. :label="label"
  124. :value="parseInt(value)">{{ label }}
  125. </a-select-option>
  126. </a-select>
  127. </a-form-item>
  128. </a-col>
  129. </a-row>
  130. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  131. <a-col :lg="12" :md="24" :sm="24">
  132. <a-form-item
  133. label="资产"
  134. :labelCol="BaseTool.Constant.labelCol"
  135. :wrapperCol="BaseTool.Constant.wrapperCol"
  136. >
  137. <a-input
  138. v-decorator="['financingNo']" />
  139. </a-form-item>
  140. </a-col>
  141. <a-col :lg="12" :md="24" :sm="24">
  142. <a-form-item
  143. label="状态"
  144. :labelCol="BaseTool.Constant.labelCol"
  145. :wrapperCol="BaseTool.Constant.wrapperCol"
  146. >
  147. <a-select v-decorator="['status', {rules: [{required: true, message: '状态不能为空'}]}]" placeholder="请选择">
  148. <a-select-option
  149. v-for="(label,value) in statusMap"
  150. :key="value"
  151. :label="label"
  152. :value="parseInt(value)">{{ label }}
  153. </a-select-option>
  154. </a-select>
  155. </a-form-item>
  156. </a-col>
  157. </a-row>
  158. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  159. <a-col :lg="12" :md="24" :sm="24">
  160. <a-form-item
  161. label="大小/尺寸"
  162. :labelCol="BaseTool.Constant.labelCol"
  163. :wrapperCol="BaseTool.Constant.wrapperCol"
  164. >
  165. <a-input
  166. v-decorator="['zz']" />
  167. </a-form-item>
  168. </a-col>
  169. <a-col :lg="12" :md="24" :sm="24">
  170. <a-form-item
  171. label="系列号"
  172. :labelCol="BaseTool.Constant.labelCol"
  173. :wrapperCol="BaseTool.Constant.wrapperCol"
  174. >
  175. <a-input
  176. v-decorator="['zzh']" />
  177. </a-form-item>
  178. </a-col>
  179. </a-row>
  180. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  181. <a-col :lg="12" :md="24" :sm="24">
  182. <a-form-item
  183. label="房间"
  184. :labelCol="BaseTool.Constant.labelCol"
  185. :wrapperCol="BaseTool.Constant.wrapperCol"
  186. >
  187. <a-input
  188. v-decorator="['cph']" />
  189. </a-form-item>
  190. </a-col>
  191. <a-col :lg="12" :md="24" :sm="24">
  192. <a-form-item
  193. label="生产商"
  194. :labelCol="BaseTool.Constant.labelCol"
  195. :wrapperCol="BaseTool.Constant.wrapperCol"
  196. >
  197. <a-input
  198. style="width: 70%"
  199. disabled
  200. v-decorator="['producerName', {rules: [{required: true, message: '生产商不能为空'}]}]" />
  201. <a-button style="width: 30%" type="primary" @click="handleProducerSelect">选择</a-button>
  202. </a-form-item>
  203. <a-form-item
  204. label="生产商"
  205. :labelCol="BaseTool.Constant.labelCol"
  206. :wrapperCol="BaseTool.Constant.wrapperCol"
  207. v-show="false"
  208. >
  209. <a-input
  210. v-decorator="['producerId', {rules: [{required: true, message: '生产商不能为空'}]}]" />
  211. </a-form-item>
  212. </a-col>
  213. </a-row>
  214. <title-divider title="基本信息" width="90px"></title-divider>
  215. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  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. disabled
  224. style="width: 80%"
  225. v-decorator="['parentSbName']"/>
  226. <a-button type="primary" style="width: 20%" @click="handleSbSelect">选择</a-button>
  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-select v-decorator="['isChild']" placeholder="请选择">
  236. <a-select-option value="1">子设备</a-select-option>
  237. <a-select-option value="2">父设备</a-select-option>
  238. <a-select-option value="3">普通设备</a-select-option>
  239. </a-select>
  240. </a-form-item>
  241. </a-col>
  242. </a-row>
  243. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  244. <a-col :lg="12" :md="24" :sm="24">
  245. <a-form-item
  246. label="存放位置"
  247. :labelCol="BaseTool.Constant.labelCol"
  248. :wrapperCol="BaseTool.Constant.wrapperCol"
  249. >
  250. <a-input
  251. style="width: 100%"
  252. v-decorator="['positionId']" />
  253. </a-form-item>
  254. </a-col>
  255. <a-col :lg="12" :md="24" :sm="24">
  256. <a-form-item
  257. label="是否显示"
  258. :labelCol="BaseTool.Constant.labelCol"
  259. :wrapperCol="BaseTool.Constant.wrapperCol"
  260. >
  261. <a-select v-decorator="['isShow']" placeholder="请选择">
  262. <a-select-option value="0">不显示</a-select-option>
  263. <a-select-option value="1">显示</a-select-option>
  264. </a-select>
  265. </a-form-item>
  266. </a-col>
  267. </a-row>
  268. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  269. <a-col :lg="12" :md="24" :sm="24">
  270. <a-form-item
  271. label="备注"
  272. :labelCol="BaseTool.Constant.labelCol"
  273. :wrapperCol="BaseTool.Constant.wrapperCol"
  274. >
  275. <a-input
  276. v-decorator="['remark', {rules: [{required: false, message: '备注不能为空'}]}]" />
  277. </a-form-item>
  278. </a-col>
  279. </a-row>
  280. <title-divider title="使用信息" width="90px"></title-divider>
  281. <!-- <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  282. <a-col :lg="12" :md="24" :sm="24">
  283. <a-form-item
  284. label="所属区域"
  285. :labelCol="BaseTool.Constant.labelCol"
  286. :wrapperCol="BaseTool.Constant.wrapperCol"
  287. >
  288. <a-select @change="handleAreaChange" v-decorator="['useArea', {rules: [{required: true, message: '所属区域不能为空'}]}]" placeholder="请选择">
  289. <a-select-option
  290. v-for="({deptId, name}) in areaList"
  291. :key="deptId"
  292. :label="name"
  293. :value="deptId">{{ name }}
  294. </a-select-option>
  295. </a-select>
  296. </a-form-item>
  297. </a-col>
  298. <a-col :lg="12" :md="24" :sm="24">
  299. <a-form-item
  300. label="所属公司"
  301. :labelCol="BaseTool.Constant.labelCol"
  302. :wrapperCol="BaseTool.Constant.wrapperCol"
  303. >
  304. <a-select @change="handleCompanyChange" v-decorator="['useCompany', {rules: [{required: true, message: '所属公司不能为空'}]}]" placeholder="请选择">
  305. <a-select-option
  306. v-for="({deptId, name}) in companyList"
  307. :key="deptId"
  308. :label="name"
  309. :value="deptId">{{ name }}
  310. </a-select-option>
  311. </a-select>
  312. </a-form-item>
  313. </a-col>
  314. </a-row>
  315. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  316. <a-col :lg="12" :md="24" :sm="24">
  317. <a-form-item
  318. label="所属项目部"
  319. :labelCol="BaseTool.Constant.labelCol"
  320. :wrapperCol="BaseTool.Constant.wrapperCol"
  321. >
  322. <a-select @change="handleProjectChange" v-decorator="['useProject', {rules: [{required: true, message: '项目部不能为空'}]}]" placeholder="请选择">
  323. <a-select-option
  324. v-for="({deptId, name}) in projectList"
  325. :key="deptId"
  326. :label="name"
  327. :value="deptId">{{ name }}
  328. </a-select-option>
  329. </a-select>
  330. </a-form-item>
  331. </a-col>
  332. <a-col :lg="12" :md="24" :sm="24">
  333. <a-form-item
  334. label="所属部门"
  335. :labelCol="BaseTool.Constant.labelCol"
  336. :wrapperCol="BaseTool.Constant.wrapperCol"
  337. >
  338. <a-select @change="handleDeptChange" v-decorator="['useDept', {rules: [{required: true, message: '所属公司不能为空'}]}]" placeholder="请选择">
  339. <a-select-option
  340. v-for="({deptId, name}) in deptList"
  341. :key="deptId"
  342. :label="name"
  343. :value="deptId">{{ name }}
  344. </a-select-option>
  345. </a-select>
  346. </a-form-item>
  347. </a-col>
  348. </a-row>-->
  349. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  350. <!-- <a-col :lg="12" :md="24" :sm="24">
  351. <a-form-item
  352. label="所属班组"
  353. :labelCol="BaseTool.Constant.labelCol"
  354. :wrapperCol="BaseTool.Constant.wrapperCol"
  355. >
  356. <a-select @change="handleGroupChange" v-decorator="['useGroup', {rules: [{required: true, message: '项目部不能为空'}]}]" placeholder="请选择">
  357. <a-select-option
  358. v-for="({deptId, name}) in groupList"
  359. :key="deptId"
  360. :label="name"
  361. :value="deptId">{{ name }}
  362. </a-select-option>
  363. </a-select>
  364. </a-form-item>
  365. </a-col>-->
  366. <a-col :lg="12" :md="24" :sm="24">
  367. <a-form-item
  368. label="保管人"
  369. :labelCol="BaseTool.Constant.labelCol"
  370. :wrapperCol="BaseTool.Constant.wrapperCol"
  371. >
  372. <a-select v-decorator="['saveUser', {rules: [{required: true, message: '项目部不能为空'}]}]" placeholder="请选择">
  373. <a-select-option
  374. v-for="({userId, realName}) in userList"
  375. :key="userId"
  376. :label="realName"
  377. :value="userId">{{ realName }}
  378. </a-select-option>
  379. </a-select>
  380. </a-form-item>
  381. </a-col>
  382. <a-col :lg="12" :md="24" :sm="24">
  383. <a-form-item
  384. label="维修人"
  385. :labelCol="BaseTool.Constant.labelCol"
  386. :wrapperCol="BaseTool.Constant.wrapperCol"
  387. >
  388. <a-select v-decorator="['repairUser']" placeholder="请选择">
  389. <a-select-option
  390. v-for="({userId, realName}) in userList"
  391. :key="userId"
  392. :label="realName"
  393. :value="userId">{{ realName }}
  394. </a-select-option>
  395. </a-select>
  396. </a-form-item>
  397. </a-col>
  398. </a-row>
  399. <title-divider title="日期信息" width="90px"></title-divider>
  400. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  401. <a-col :lg="12" :md="24" :sm="24">
  402. <a-form-item
  403. label="购置日期"
  404. :labelCol="BaseTool.Constant.labelCol"
  405. :wrapperCol="BaseTool.Constant.wrapperCol"
  406. >
  407. <a-date-picker
  408. style="width: 100%"
  409. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  410. v-decorator="['buyDate']" />
  411. </a-form-item>
  412. </a-col>
  413. <a-col :lg="12" :md="24" :sm="24">
  414. <a-form-item
  415. label="投用日期"
  416. :labelCol="BaseTool.Constant.labelCol"
  417. :wrapperCol="BaseTool.Constant.wrapperCol"
  418. >
  419. <a-date-picker
  420. style="width: 100%"
  421. :format="BaseTool.Date.PICKER_NORM_DATE_PATTERN"
  422. v-decorator="['startDate']" />
  423. </a-form-item>
  424. </a-col>
  425. </a-row>
  426. <title-divider title="文件信息" width="90px"></title-divider>
  427. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  428. <a-col :lg="12" :md="24" :sm="24">
  429. <a-form-item
  430. label="维保手册"
  431. :labelCol="BaseTool.Constant.labelCol"
  432. :wrapperCol="BaseTool.Constant.wrapperCol"
  433. >
  434. <a-upload
  435. :action="uploadUrl"
  436. :file-list="this.defaultRepairFileList"
  437. @change="handleRepairFileChange"
  438. :headers="headers"
  439. >
  440. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  441. </a-upload>
  442. </a-form-item>
  443. </a-col>
  444. <a-col :lg="12" :md="24" :sm="24">
  445. <a-form-item
  446. label="使用手册"
  447. :labelCol="BaseTool.Constant.labelCol"
  448. :wrapperCol="BaseTool.Constant.wrapperCol"
  449. >
  450. <a-upload
  451. :action="uploadUrl"
  452. :multiple="true"
  453. :file-list="this.defaultUseFileList"
  454. @change="handleUseFileChange"
  455. :headers="headers"
  456. >
  457. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  458. </a-upload>
  459. </a-form-item>
  460. </a-col>
  461. </a-row>
  462. <a-row class="form-row" :gutter="BaseTool.Constant.row.gutter">
  463. <a-col :lg="12" :md="24" :sm="24">
  464. <a-form-item
  465. label="验收文件"
  466. :labelCol="BaseTool.Constant.labelCol"
  467. :wrapperCol="BaseTool.Constant.wrapperCol"
  468. >
  469. <a-upload
  470. :action="uploadUrl"
  471. :multiple="false"
  472. :file-list="this.defaultRecheckFileList"
  473. @change="handleRecheckFileChange"
  474. :headers="headers"
  475. >
  476. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  477. </a-upload>
  478. </a-form-item>
  479. </a-col>
  480. <a-col :lg="12" :md="24" :sm="24">
  481. <a-form-item
  482. label="设备图片"
  483. :labelCol="BaseTool.Constant.labelCol"
  484. :wrapperCol="BaseTool.Constant.wrapperCol"
  485. >
  486. <a-upload
  487. :action="uploadUrl"
  488. :multiple="true"
  489. :file-list="this.defaultSbFileList"
  490. @change="handleSbFileChange"
  491. accept="image/*"
  492. :headers="headers"
  493. >
  494. <a-button> <a-icon type="upload" /> 选择上传文件 </a-button>
  495. </a-upload>
  496. </a-form-item>
  497. </a-col>
  498. </a-row>
  499. </a-form>
  500. <sb-model-select-modal ref="sbModelSelectModal" @selected="handleSbModelSelected"/>
  501. <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
  502. <firm-producer-select-modal ref="producerSelectModal" @selected="handleProducerSelected"/>
  503. </a-card>
  504. </template>
  505. <script>
  506. import pick from 'lodash.pick'
  507. import { addSbInfo, updateSbInfo } from '@/api/sb/info'
  508. import { fetchSbTypeTree } from '@/api/sb/type'
  509. import FirmProducerSelectModal from '@/views/firm/producer/modules/FirmProducerSelectModal'
  510. import SbGuigeSelectModal from '@/views/sb/guige/modules/SbGuigeSelectModal'
  511. import SbModelSelectModal from '@/views/sb/model/modules/SbModelSelectModal'
  512. import BaseTool from '../../../../utils/tool'
  513. import { queryUserDeptByUserDeptId } from '@/api/upms/user-dept'
  514. import { ACCESS_TOKEN } from '@/store/mutation-types'
  515. import Vue from 'vue'
  516. import { uploadUrl } from '@/api/upms/file'
  517. import { queryDept, getDeptsAllByParentId } from '@/api/upms/dept'
  518. import { queryUser } from '@/api/upms/user'
  519. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  520. export default {
  521. name: 'BaseSbInfo',
  522. components: {
  523. FirmProducerSelectModal,
  524. SbGuigeSelectModal,
  525. SbModelSelectModal,
  526. SbInfoSelectModal
  527. },
  528. data () {
  529. return {
  530. confirmLoading: false,
  531. modalTitle: null,
  532. form: this.$form.createForm(this),
  533. areaList: {},
  534. companyList: {},
  535. projectList: {},
  536. deptList: {},
  537. groupList: {},
  538. visible: false,
  539. sbTypeTreeData: [],
  540. // sbInfoTreeData: [],
  541. // sourceSbInfoTreeData: [],
  542. // sbPositionTreeData: [],
  543. depreciationTypeMap: {},
  544. sourceTypeMap: {},
  545. levelMap: {},
  546. rlTypeMap: {},
  547. colorMap: {},
  548. useTypeMap: {},
  549. statusMap: {},
  550. userList: {},
  551. unitMap: {},
  552. sbInfoSelectType: null,
  553. repairFileList: [], // 维修手册
  554. defaultRepairFileList: [],
  555. defaultUseFileList: [],
  556. defaultRecheckFileList: [],
  557. defaultSbFileList: [],
  558. useFileList: [], // 使用手册
  559. recheckFileList: [], // 验收手册
  560. sbFileList: [], // 设备图片,
  561. uploadUrl: uploadUrl,
  562. qrcodesrc: null,
  563. fileList: [],
  564. headers: {
  565. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  566. }
  567. }
  568. },
  569. props: {
  570. },
  571. created () {
  572. this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
  573. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
  574. this.colorMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_COLOR)
  575. this.rlTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.RANLIAO_TYPE)
  576. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  577. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  578. this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
  579. this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_USE_TYPE)
  580. },
  581. methods: {
  582. base (record) {
  583. this.setTree(record)
  584. // 清除文件列表
  585. this.visible = true
  586. // 选择框查询条件
  587. // 如果是空标识添加
  588. if (this.BaseTool.Object.isBlank(record)) {
  589. this.qrcodesrc = null
  590. this.modalTitle = '添加'
  591. this.clearFileList()
  592. return
  593. }
  594. this.modalTitle = '编辑'
  595. this.qrcodesrc = record.qrCode
  596. this.repairFileList = record.repairFileList
  597. this.defaultRepairFileList = this.BaseTool.UPLOAD.transImg(this.repairFileList)
  598. this.useFileList = record.useFileList
  599. this.recheckFileList = record.recheckFileList
  600. this.sbFileList = record.sbFileList
  601. this.defaultUseFileList = this.BaseTool.UPLOAD.transImg(this.useFileList)
  602. this.defaultRecheckFileList = this.BaseTool.UPLOAD.transImg(this.recheckFileList)
  603. this.defaultSbFileList = this.BaseTool.UPLOAD.transImg(this.sbFileList)
  604. // if (this.BaseTool.Object.isBlank(record.id)) {
  605. // this.modalTitle = '复制'
  606. // this.qrcodesrc = null
  607. // record.no = null
  608. // this.clearFileList()
  609. // }
  610. if(record.isChild == 1){
  611. record.isChild = "1"
  612. }
  613. if(record.isChild == 2){
  614. record.isChild = "2"
  615. }
  616. if(record.isChild == 3){
  617. record.isChild = "3"
  618. }
  619. if(record.isShow == 0){
  620. record.isShow = "0"
  621. }
  622. if(record.isShow == 1){
  623. record.isShow = "1"
  624. }
  625. const { form: { setFieldsValue } } = this
  626. // 日期处理
  627. record.buyDate = this.BaseTool.Moment(record.buyDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  628. record.startDate = this.BaseTool.Moment(record.startDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  629. record.nextCheckDate = this.BaseTool.Moment(record.nextCheckDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  630. record.guaranteeDate = this.BaseTool.Moment(record.guaranteeDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  631. record.retirementDate = this.BaseTool.Moment(record.retirementDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  632. // record.lastRepaireTime = this.BaseTool.Moment(record.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  633. // record.lastBaoyangTime = this.BaseTool.Moment(record.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  634. if (record.jbdDate != null) {
  635. record.jbdDate = this.BaseTool.Moment(record.jbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  636. this.$nextTick(() => {
  637. setFieldsValue(Object.assign(pick(record, [
  638. 'jbdDate'
  639. ])))
  640. })
  641. }
  642. if (record.sbdDate != null) {
  643. record.sbdDate = this.BaseTool.Moment(record.sbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  644. this.$nextTick(() => {
  645. setFieldsValue(Object.assign(pick(record, [
  646. 'sbdDate'
  647. ])))
  648. })
  649. }
  650. if (record.sbDate != null) {
  651. record.sbDate = this.BaseTool.Moment(record.sbDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  652. this.$nextTick(() => {
  653. setFieldsValue(Object.assign(pick(record, [
  654. 'sbDate'
  655. ])))
  656. })
  657. }
  658. if (record.spDate != null) {
  659. record.spDate = this.BaseTool.Moment(record.spDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  660. this.$nextTick(() => {
  661. setFieldsValue(Object.assign(pick(record, [
  662. 'spDate'
  663. ])))
  664. })
  665. }
  666. record.unitName = this.BaseTool.Object.getField(this.unitMap, record.unit)
  667. record.useTypeName = this.BaseTool.Object.getField(this.useTypeMap, record.useType)
  668. this.$nextTick(() => {
  669. setFieldsValue(Object.assign(pick(record, [
  670. 'id',
  671. 'no',
  672. 'parentId',
  673. 'parentSbName',
  674. 'isChild',
  675. 'isShow',
  676. 'financingNo',
  677. 'name',
  678. 'model',
  679. 'positionId',
  680. 'producerName',
  681. 'useArea',
  682. 'useCompany',
  683. 'useProject',
  684. 'useDept',
  685. 'saveUser',
  686. 'repairUser',
  687. 'useGroup',
  688. 'typeId',
  689. 'level',
  690. 'initialValue',
  691. // 'cutValue',
  692. 'producerId',
  693. // 'sourceType',
  694. 'unit',
  695. 'buyDate',
  696. 'startDate',
  697. 'zbh',
  698. // 'wbFile',
  699. // 'useFile',
  700. // 'checkFile',
  701. // 'sbImage',
  702. 'status',
  703. 'remark',
  704. 'zzh',
  705. 'zz',
  706. 'useType'
  707. ])))
  708. })
  709. },
  710. save () {
  711. const { form: { validateFieldsAndScroll } } = this
  712. this.confirmLoading = true
  713. validateFieldsAndScroll((errors, values) => {
  714. if (errors) {
  715. this.confirmLoading = false
  716. return
  717. }
  718. // 日期数据的处理
  719. values.buyDate = BaseTool.Date.formatter(values.buyDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  720. values.startDate = BaseTool.Date.formatter(values.startDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  721. values.nextCheckDate = BaseTool.Date.formatter(values.nextCheckDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  722. values.guaranteeDate = BaseTool.Date.formatter(values.guaranteeDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  723. values.retirementDate = BaseTool.Date.formatter(values.retirementDate, BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  724. values.lastRepaireTime = this.BaseTool.Date.formatter(values.lastRepaireTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  725. values.lastBaoyangTime = this.BaseTool.Date.formatter(values.lastBaoyangTime, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  726. values.spDate = this.BaseTool.Date.formatter(values.spDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  727. values.jbdDate = this.BaseTool.Date.formatter(values.jbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  728. values.sbdDate = this.BaseTool.Date.formatter(values.sbdDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  729. values.sbDate = this.BaseTool.Date.formatter(values.sbDate, this.BaseTool.Date.PICKER_NORM_DATE_PATTERN)
  730. // 上传文件
  731. values.repairFileList = this.repairFileList
  732. values.useFileList = this.useFileList
  733. values.recheckFileList = this.recheckFileList
  734. values.sbFileList = this.sbFileList
  735. if (this.BaseTool.String.isBlank(values.id)) {
  736. addSbInfo(values)
  737. .then(() => {
  738. this.handleCancel(values)
  739. }).catch(() => {
  740. this.confirmLoading = false
  741. })
  742. } else {
  743. updateSbInfo(values)
  744. .then(() => {
  745. this.handleCancel(values)
  746. }).catch(() => {
  747. this.confirmLoading = false
  748. })
  749. }
  750. })
  751. },
  752. getQrcodeSrc () {
  753. console.log(111, 22)
  754. },
  755. handleCancel () {
  756. this.visible = false
  757. this.confirmLoading = false
  758. this.form.resetFields()
  759. this.$emit('ok')
  760. },
  761. setTree (record = {}) {
  762. fetchSbTypeTree().then(res => {
  763. this.sbTypeTreeData = res.data
  764. })
  765. // getSbInfoTree({ id: record.id }).then(res => {
  766. // this.sbInfoTreeData = res.data
  767. // this.sourceSbInfoTreeData = res.data
  768. // })
  769. // getSbPositionTree().then(res => {
  770. // this.sbPositionTreeData = res.data
  771. // })
  772. queryDept({ nature: this.DictCache.VALUE.SYS_DEPT_NATURE.JITUAN }).then(res => {
  773. this.areaList = res.data
  774. })
  775. if (record.useArea != null) {
  776. getDeptsAllByParentId({ deptId: record.useArea, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  777. this.companyList = res.data
  778. })
  779. getDeptsAllByParentId({ deptId: record.useCompany, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU }).then(res => {
  780. this.projectList = res.data
  781. })
  782. getDeptsAllByParentId({ deptId: record.useProject, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BU_MEN }).then(res => {
  783. this.deptList = res.data
  784. })
  785. getDeptsAllByParentId({ deptId: record.useDept, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BAN_ZU }).then(res => {
  786. this.groupList = res.data
  787. })
  788. queryUser({ }).then(res => {
  789. this.userList = res.data
  790. })
  791. }
  792. queryUser({ }).then(res => {
  793. this.userList = res.data
  794. })
  795. },
  796. handleSbModelSelect () {
  797. const modal = this.$refs.sbModelSelectModal
  798. modal.base()
  799. },
  800. handleSbModelSelected (keys, rows) {
  801. const [ key ] = keys
  802. const [ row ] = rows
  803. const { form: { setFieldsValue } } = this
  804. this.$nextTick(() => {
  805. setFieldsValue({
  806. 'modelId': key,
  807. 'name': row.name,
  808. 'model': row.model,
  809. 'nameModel': row.nameModel,
  810. 'typeId': row.typeId,
  811. 'typeName': row.typeName,
  812. 'level': row.level,
  813. 'initialValue': row.value,
  814. 'useType': row.useType,
  815. 'useTypeName': this.BaseTool.Object.getField(this.useTypeMap, row.useType),
  816. 'producerId': row.producerId,
  817. 'producerName': row.producerName,
  818. 'unit': row.unit,
  819. 'unitName': this.BaseTool.Object.getField(this.unitMap, row.unit)
  820. })
  821. })
  822. },
  823. beforeRecheckFileListUpload (file) {
  824. const reg = /\.(xls|xlsx)(\?.*)?$/
  825. return new Promise((resolve, reject) => {
  826. if (reg.test(file.name)) {
  827. this.recheckFileList = [file]
  828. return true
  829. } else {
  830. this.$message.error(`请上传正确的xls|xlsx文件`)
  831. reject(new Error('请上传正确的xls|xlsx文件'))
  832. return false
  833. }
  834. })
  835. },
  836. beforeUploadPic (file) {
  837. const reg = /\.(jpg|jpeg|png)(\?.*)?$/
  838. return new Promise((resolve, reject) => {
  839. if (reg.test(file.name)) {
  840. this.sbFileList = [file]
  841. return true
  842. } else {
  843. this.$message.error(`请上传正确的jpg|jpeg|png文件`)
  844. reject(new Error('请上传正确的jpg|jpeg|png文件'))
  845. return false
  846. }
  847. })
  848. },
  849. clearFileList () {
  850. this.repairFileList = []
  851. this.useFileList = []
  852. this.recheckFileList = []
  853. this.sbFileList = []
  854. },
  855. handleRepairFileChange (info) {
  856. this.defaultRepairFileList = info.fileList
  857. this.repairFileList = this.setFileList(info, 1)
  858. },
  859. handleUseFileChange (info) {
  860. this.defaultUseFileList = info.fileList
  861. this.useFileList = this.setFileList(info, 2)
  862. },
  863. handleAreaChange (value) {
  864. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.FEN_GONG_SI }).then(res => {
  865. this.companyList = res.data
  866. })
  867. },
  868. handleCompanyChange (value) {
  869. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.XIANG_MU_BU }).then(res => {
  870. this.projectList = res.data
  871. })
  872. },
  873. handleProjectChange (value) {
  874. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BU_MEN }).then(res => {
  875. this.deptList = res.data
  876. })
  877. },
  878. handleDeptChange (value) {
  879. getDeptsAllByParentId({ deptId: value, nature: this.DictCache.VALUE.SYS_DEPT_NATURE.BAN_ZU }).then(res => {
  880. this.groupList = res.data
  881. })
  882. },
  883. handleGroupChange (value) {
  884. queryUserDeptByUserDeptId({ deptId: value }).then(res => {
  885. this.userList = res.data
  886. })
  887. },
  888. handleRecheckFileChange (info) {
  889. this.defaultRecheckFileList = info.fileList
  890. this.recheckFileList = this.setFileList(info, 3)
  891. },
  892. handleSbFileChange (info) {
  893. this.defaultSbFileList = info.fileList
  894. this.sbFileList = this.setFileList(info, 4)
  895. },
  896. setFileList1 (info, type) {
  897. const fileList = [...info.fileList]
  898. const file = [...info.file]
  899. if (file.status === 'done') {
  900. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  901. } else if (file.status === 'removed') {
  902. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  903. } else if (file.status === 'error') {
  904. this.$message.error('上传失败')
  905. return []
  906. }
  907. },
  908. handleSbSelect () {
  909. this.$refs.sbInfoSelectModal.base({}, { isChild: this.DictCache.VALUE.SB_IS_CHILD.IS_PARENT })
  910. },
  911. handleSbSelectd (keys, rows) {
  912. const [ key ] = keys
  913. const [ row ] = rows
  914. const { form: { setFieldsValue } } = this
  915. // 日期处理
  916. this.$nextTick(() => {
  917. setFieldsValue(Object.assign({
  918. 'parentId': key,
  919. 'parentSbName': row.name,
  920. 'isChild': this.DictCache.VALUE.SB_IS_CHILD.IS_CHILD
  921. }))
  922. })
  923. },
  924. handleProducerSelect () {
  925. const modal = this.$refs.producerSelectModal
  926. modal.base({}, { type: 1 })
  927. },
  928. handleProducerSelected (record, selectedRowKeys, selectedRow) {
  929. const { form: { setFieldsValue } } = this
  930. const [ key ] = selectedRowKeys
  931. const [ row ] = selectedRow
  932. setFieldsValue({
  933. 'producerId': key,
  934. 'producerName': row.name
  935. })
  936. },
  937. setFileList (info, type) {
  938. // { file, fileList }
  939. const file = info.file
  940. const fileList = info.fileList
  941. // fileList = fileList.slice(-2)
  942. // console.log(111, this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type))
  943. if (file.status === 'done') {
  944. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  945. } else if (file.status === 'removed') {
  946. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  947. } else if (file.status === 'error') {
  948. this.$message.error('上传失败')
  949. return null
  950. }
  951. // return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  952. // 1. Limit the number of uploaded files
  953. // Only to show two recent uploaded files, and old ones will be replaced by the new
  954. // fileList = fileList.slice(-2)
  955. // 2. read from response and show file link
  956. // fileList = fileList.map(file => {
  957. // if (file.response) {
  958. // // Component will show file.url as link
  959. // const { response: { data } } = file
  960. // file.url = data.url
  961. // file.fileName = data.fileName
  962. // file.fileFormat = data.fileFormat
  963. // file.name = data.name
  964. // file.type = type
  965. // }
  966. // return file
  967. // })
  968. // console.log(6666, fileList)
  969. // return fileList
  970. }
  971. }
  972. }
  973. </script>