BaseForm.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  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 style="margin-left: 8px" 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. <a-form :form="form">
  12. <a-form-item v-show="false" >
  13. <a-input v-decorator="['id']" type="hidden"/>
  14. <a-input v-decorator="['sbId']" type="hidden"/>
  15. <a-input v-decorator="['typeId']" type="hidden"/>
  16. </a-form-item>
  17. <a-form-item v-show="false" >
  18. <a-input v-decorator="['unit']" type="hidden"/>
  19. </a-form-item>
  20. <a-form-item v-show="false" >
  21. <a-input v-decorator="['unitBz']" type="hidden"/>
  22. </a-form-item>
  23. <a-form-item v-show="false">
  24. <a-input v-decorator="['producerId']" />
  25. </a-form-item>
  26. <a-form-item v-show="false">
  27. <a-input v-decorator="['supplierId']" />
  28. </a-form-item>
  29. <title-divider title="基础信息" width="100px"></title-divider>
  30. <row-list :col="2">
  31. <row-item>
  32. <a-form-item
  33. label="类别"
  34. :labelCol="BaseTool.Constant.labelCol"
  35. :wrapperCol="BaseTool.Constant.wrapperCol"
  36. >
  37. <a-tree-select
  38. style="width: 100%"
  39. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  40. :treeData="spareTypeData"
  41. :treeNodeFilterProp="'title'"
  42. :showSearch="true"
  43. v-decorator="['parentTypeId', {rules: [{required: true, message: '类别不能为空'}]}]"
  44. placeholder="请选择"
  45. >
  46. </a-tree-select>
  47. </a-form-item>
  48. </row-item>
  49. <row-item>
  50. <a-form-item
  51. label="备件名称"
  52. :labelCol="BaseTool.Constant.labelCol"
  53. :wrapperCol="BaseTool.Constant.wrapperCol"
  54. >
  55. <a-input
  56. v-decorator="['name', {rules: [{required: true, message: '设备名称不能为空'}]}]" />
  57. </a-form-item>
  58. </row-item>
  59. <row-item>
  60. <a-form-item
  61. label="规格型号"
  62. :labelCol="BaseTool.Constant.labelCol"
  63. :wrapperCol="BaseTool.Constant.wrapperCol"
  64. >
  65. <a-input
  66. v-decorator="['ggxh']" />
  67. </a-form-item>
  68. </row-item>
  69. <row-item>
  70. <a-form-item
  71. label="生产商"
  72. :labelCol="BaseTool.Constant.labelCol"
  73. :wrapperCol="BaseTool.Constant.wrapperCol"
  74. >
  75. <a-input
  76. style="width: 70%"
  77. disabled
  78. v-decorator="['producerName']" />
  79. <a-button style="width: 30%" type="primary" @click="handleProducerSelect">选择</a-button>
  80. </a-form-item>
  81. </row-item>
  82. <row-item>
  83. <a-form-item
  84. label="备件价值"
  85. :labelCol="BaseTool.Constant.labelCol"
  86. :wrapperCol="BaseTool.Constant.wrapperCol"
  87. >
  88. <a-input-number
  89. style="width: 100%"
  90. :min="0"
  91. :step="0.01"
  92. :formatter="BaseTool.Amount.formatter"
  93. :parser="BaseTool.Amount.parser"
  94. v-decorator="['initialValue', {rules: [{required: true, message: '备件价值不能为空'}]}]" />
  95. </a-form-item>
  96. </row-item>
  97. <row-item>
  98. <a-form-item
  99. label="采购供应商"
  100. :labelCol="BaseTool.Constant.labelCol"
  101. :wrapperCol="BaseTool.Constant.wrapperCol"
  102. >
  103. <a-input
  104. style="width: 70%"
  105. disabled
  106. v-decorator="['supplierName']" />
  107. <a-button style="width: 30%" type="primary" @click="handleSupplierSelect">选择</a-button>
  108. </a-form-item>
  109. </row-item>
  110. <row-item>
  111. <a-form-item
  112. label="备件编号"
  113. :labelCol="BaseTool.Constant.labelCol"
  114. :wrapperCol="BaseTool.Constant.wrapperCol"
  115. >
  116. <a-input
  117. v-decorator="['no', {rules: [{required: false, message: '备件编码不能为空'}]}]" />
  118. </a-form-item>
  119. </row-item>
  120. <row-item>
  121. <a-form-item
  122. label="原厂编号"
  123. :labelCol="BaseTool.Constant.labelCol"
  124. :wrapperCol="BaseTool.Constant.wrapperCol"
  125. >
  126. <a-input
  127. style="width: 100%"
  128. v-decorator="['initNo']" />
  129. </a-form-item>
  130. </row-item>
  131. <row-item>
  132. <a-form-item
  133. label="自编号"
  134. :labelCol="BaseTool.Constant.labelCol"
  135. :wrapperCol="BaseTool.Constant.wrapperCol"
  136. >
  137. <a-input
  138. v-decorator="['zbh', {rules: [{required: false, message: '自编号不能为空'}]}]" />
  139. </a-form-item>
  140. </row-item>
  141. <row-item>
  142. <a-form-item
  143. label="助记码"
  144. :labelCol="BaseTool.Constant.labelCol"
  145. :wrapperCol="BaseTool.Constant.wrapperCol"
  146. >
  147. <a-input
  148. v-decorator="['zjm']" />
  149. </a-form-item>
  150. </row-item>
  151. <row-item>
  152. <a-form-item
  153. label="备件等级"
  154. :labelCol="BaseTool.Constant.labelCol"
  155. :wrapperCol="BaseTool.Constant.wrapperCol"
  156. >
  157. <a-select v-decorator="['level', {initialValue: 1}]" placeholder="请选择">
  158. <a-select-option
  159. v-for="(label,value) in levelMap"
  160. :key="value"
  161. :label="label"
  162. :value="parseInt(value)">{{ label }}
  163. </a-select-option>
  164. </a-select>
  165. </a-form-item>
  166. </row-item>
  167. <row-item>
  168. <a-form-item
  169. label="计量单位"
  170. :labelCol="BaseTool.Constant.labelCol"
  171. :wrapperCol="BaseTool.Constant.wrapperCol"
  172. >
  173. <a-select
  174. show-search
  175. :value="unitName"
  176. :default-active-first-option="false"
  177. :show-arrow="true"
  178. :filter-option="true"
  179. :not-found-content="null"
  180. @search="handleSearch"
  181. @blur="handleBlur"
  182. @change="handleChange">
  183. <a-select-option
  184. v-for="(label,value) in unitMap"
  185. :key="value"
  186. :label="label"
  187. :value="label">{{ label }}
  188. </a-select-option>
  189. </a-select>
  190. </a-form-item>
  191. </row-item>
  192. <!-- <row-item>
  193. <a-form-item
  194. label="包装单位"
  195. :labelCol="BaseTool.Constant.labelCol"
  196. :wrapperCol="BaseTool.Constant.wrapperCol"
  197. >
  198. <a-select
  199. show-search
  200. :value="unitNameBz"
  201. :default-active-first-option="false"
  202. :show-arrow="true"
  203. :filter-option="true"
  204. :not-found-content="null"
  205. @search="handleSearchBz"
  206. @blur="handleBlurBz"
  207. @change="handleChangeBz">
  208. <a-select-option
  209. v-for="(label,value) in unitMap"
  210. :key="value"
  211. :label="label"
  212. :value="label">{{ label }}
  213. </a-select-option>
  214. </a-select>
  215. </a-form-item>
  216. </row-item>
  217. <row-item>
  218. <a-form-item
  219. label="折算系数"
  220. :labelCol="BaseTool.Constant.labelCol"
  221. :wrapperCol="BaseTool.Constant.wrapperCol"
  222. >
  223. <a-input
  224. placeholder="单位折算为包装单位,如24个单位包装为一箱"
  225. v-decorator="['unitRate']" />
  226. </a-form-item>
  227. </row-item>-->
  228. <row-item>
  229. <a-form-item
  230. label="采购周期"
  231. :labelCol="BaseTool.Constant.labelCol"
  232. :wrapperCol="BaseTool.Constant.wrapperCol"
  233. >
  234. <a-input suffix="天" v-decorator="['purchasePeriod']" />
  235. </a-form-item>
  236. </row-item>
  237. <row-item>
  238. <a-form-item
  239. label="使用周期"
  240. :labelCol="BaseTool.Constant.labelCol"
  241. :wrapperCol="BaseTool.Constant.wrapperCol"
  242. >
  243. <a-input suffix="月" v-decorator="['usePeriod']" />
  244. </a-form-item>
  245. </row-item>
  246. <row-item>
  247. <a-form-item
  248. label="寿命周期"
  249. :labelCol="BaseTool.Constant.labelCol"
  250. :wrapperCol="BaseTool.Constant.wrapperCol"
  251. >
  252. <a-input suffix="月" v-decorator="['agePeriod']" />
  253. </a-form-item>
  254. </row-item>
  255. <row-item>
  256. <a-form-item
  257. label="最高库存"
  258. :labelCol="BaseTool.Constant.labelCol"
  259. :wrapperCol="BaseTool.Constant.wrapperCol"
  260. >
  261. <a-input-number
  262. style="width: 100%"
  263. :min="1"
  264. v-decorator="['maxStock']" />
  265. </a-form-item>
  266. </row-item>
  267. <row-item>
  268. <a-form-item
  269. label="最低库存"
  270. :labelCol="BaseTool.Constant.labelCol"
  271. :wrapperCol="BaseTool.Constant.wrapperCol"
  272. >
  273. <a-input-number
  274. style="width: 100%"
  275. :min="1"
  276. v-decorator="['minStock']" />
  277. </a-form-item>
  278. </row-item>
  279. <row-item v-show="isAdd">
  280. <a-form-item
  281. label="初始库位"
  282. :labelCol="BaseTool.Constant.labelCol"
  283. :wrapperCol="BaseTool.Constant.wrapperCol"
  284. >
  285. <a-tree-select
  286. style="width: 100%"
  287. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  288. :treeData="storeTreeDate"
  289. :treeNodeFilterProp="'title'"
  290. :showSearch="true"
  291. v-decorator="['storeId', {rules: [{required: false, message: '仓库库位不能为空'}]}]"
  292. placeholder="请选择"
  293. >
  294. </a-tree-select>
  295. </a-form-item>
  296. </row-item>
  297. <row-item v-show="isAdd">
  298. <a-form-item
  299. label="初始库存"
  300. :labelCol="BaseTool.Constant.labelCol"
  301. :wrapperCol="BaseTool.Constant.wrapperCol"
  302. >
  303. <a-input-number
  304. style="width: 100%"
  305. :min="1"
  306. v-decorator="['initStock']" />
  307. </a-form-item>
  308. </row-item>
  309. <row-item>
  310. <a-form-item
  311. label="英文名称"
  312. :labelCol="BaseTool.Constant.labelCol"
  313. :wrapperCol="BaseTool.Constant.wrapperCol"
  314. >
  315. <a-input
  316. v-decorator="['englishName', {rules: [{required: false, message: '英文名称不能为空'}]}]" />
  317. </a-form-item>
  318. </row-item>
  319. <row-item>
  320. <a-form-item
  321. label="产地"
  322. :labelCol="BaseTool.Constant.labelCol"
  323. :wrapperCol="BaseTool.Constant.wrapperCol"
  324. >
  325. <a-select v-decorator="['cd']" placeholder="请选择">
  326. <a-select-option
  327. v-for="(label,value) in cdMap"
  328. :key="value"
  329. :label="label"
  330. :value="parseInt(value)">{{ label }}
  331. </a-select-option>
  332. </a-select>
  333. </a-form-item>
  334. </row-item>
  335. <row-item>
  336. <a-form-item
  337. label="图片"
  338. :labelCol="BaseTool.Constant.labelCol"
  339. :wrapperCol="BaseTool.Constant.wrapperCol"
  340. >
  341. <!-- <upload-img
  342. ref="imageUpload"
  343. @catchImage="catchImage"
  344. ></upload-img>-->
  345. <upload-spare-file
  346. ref="imageUpload"
  347. @catchImage="catchImage"
  348. ></upload-spare-file>
  349. </a-form-item>
  350. </row-item>
  351. <row-item>
  352. <a-form-item
  353. label="参数"
  354. :labelCol="BaseTool.Constant.labelCol"
  355. :wrapperCol="BaseTool.Constant.wrapperCol"
  356. >
  357. <a-textarea
  358. v-decorator="['params']" />
  359. </a-form-item>
  360. </row-item>
  361. <row-item>
  362. <a-form-item
  363. label="用途"
  364. :labelCol="BaseTool.Constant.labelCol"
  365. :wrapperCol="BaseTool.Constant.wrapperCol"
  366. >
  367. <a-select v-decorator="['yt', {rules: [{required: true, message: '类型用途不能为空'}]}]" placeholder="请选择">
  368. <a-select-option
  369. v-for="(label,value) in ytMap"
  370. :key="value"
  371. :label="label"
  372. :value="parseInt(value)">{{ label }}
  373. </a-select-option>
  374. </a-select>
  375. </a-form-item>
  376. </row-item>
  377. <row-item>
  378. <a-form-item
  379. label="是否专用"
  380. :labelCol="BaseTool.Constant.labelCol"
  381. :wrapperCol="BaseTool.Constant.wrapperCol"
  382. >
  383. <a-select v-decorator="['isSpecial', {rules: [{required: true, message: '是否专用不能为空'}]}]" placeholder="请选择">
  384. <a-select-option
  385. v-for="(label,value) in specialMap"
  386. :key="value"
  387. :label="label"
  388. :value="parseInt(value)">{{ label }}
  389. </a-select-option>
  390. </a-select>
  391. </a-form-item>
  392. </row-item>
  393. <row-item>
  394. <a-form-item
  395. label="备注"
  396. :labelCol="BaseTool.Constant.labelCol"
  397. :wrapperCol="BaseTool.Constant.wrapperCol"
  398. >
  399. <a-textarea
  400. v-decorator="['remark']" />
  401. </a-form-item>
  402. </row-item>
  403. </row-list>
  404. </a-form>
  405. <title-divider title="设备信息" width="100px"></title-divider>
  406. <div class="table-operator">
  407. <a-button style="margin-left:8px;" type="primary" @click="handleSbSelect">
  408. <a-icon type="plus"/>
  409. 添加
  410. </a-button>
  411. <a-button class="margin-left8" size="small" type="danger" @click="handleDel">
  412. <a-icon type="delete"/>
  413. 删除
  414. </a-button>
  415. </div>
  416. <a-table
  417. :data-source="data"
  418. :columns="columns"
  419. bordered
  420. tableLayout="auto"
  421. :row-selection="rowSelection"
  422. rowKey="id">
  423. <span slot="action" slot-scope="record">
  424. <template>
  425. <a v-if="$auth('sb-infos-edit')" @click="handleDetailSelect(record)">修改</a>
  426. <a-divider type="vertical" />
  427. <a-popconfirm v-if="$auth('sb-infos-del')" title="是否要删除该条数据?" @confirm="handleDelOne(record.id)">
  428. <a>删除</a>
  429. </a-popconfirm>
  430. </template>
  431. </span>
  432. </a-table>
  433. <p style="color: red">仓库数量初始化注意事项:<br/>
  434. 1:初始化库存仅能选择一个库位入库<br/>
  435. 2:初始化库存仅能新增,如需要修改请在仓库管理->仓库库存中修改数量<br/>
  436. </p>
  437. <template slot="footer">
  438. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  439. </template>
  440. <firm-producer-select-modal ref="producerSelectModal" @selected="handleProducerSelected"/>
  441. <supplier-select-modal ref="supplierSelectModal" @selected="handleSupplierSelected"/>
  442. <store-select-modal ref="storeSelectModal" @selected="handleStoreSelected"/>
  443. <sb-info-select-modal :type="'checkbox'" ref="sbInfoSelectModal" @selected="handleSbSelected"/>
  444. <base-form-spare ref="baseModal" @selected="handleDetailSelected"/>
  445. </a-card>
  446. </template>
  447. <script>
  448. import pick from 'lodash.pick'
  449. import { addSparePartInfo, querySparePartInfo, updateSparePartInfo } from '@/api/sqarepartmanage/sparepartinfo'
  450. import { querySpareType, fetchSpareTypeTree } from '@/api/sqarepartmanage/sparetype'
  451. import { fetchSbGuigeOptions } from '@/api/sb/guige'
  452. import FirmProducerSelectModal from '@/views/firm/producer/modules/FirmProducerSelectModal'
  453. import SupplierSelectModal from '@/views/purchase/supplier/modules/SupplierSelectModal'
  454. import UploadSpareFile from '@/components/Upload/UploadSpareFile'
  455. import Vue from 'vue'
  456. import StoreSelectModal from '@/views/store/store/modules/StoreSelectModal'
  457. import { uploadUrl } from '@/api/upms/file'
  458. import { ACCESS_TOKEN } from '@/store/mutation-types'
  459. import { fetchStoreTree } from '@/api/store/store'
  460. import { selectSbModelListBySpareId } from '@/api/sb/modelbom'
  461. import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
  462. import BaseFormSpare from '@/views/sb/modelbom/modules/BaseFormSpare'
  463. export default {
  464. name: 'BaseSparePartInfo',
  465. components: {
  466. FirmProducerSelectModal,
  467. SupplierSelectModal,
  468. UploadSpareFile,
  469. StoreSelectModal,
  470. SbInfoSelectModal,
  471. BaseFormSpare
  472. },
  473. data () {
  474. return {
  475. isAdd: false,
  476. unitName: null,
  477. unitNameBz: null,
  478. rowSelection: {
  479. onChange: (selectedRowKeys, selectedRows) => {
  480. this.selectedRowKeys = selectedRowKeys
  481. this.selectedRows = selectedRows
  482. }
  483. },
  484. gg: null,
  485. storeTreeDate: [],
  486. uploadUrl: uploadUrl,
  487. defaultApplicationFileList: [],
  488. applicationFileList: [], // 备件图片
  489. confirmLoading: false,
  490. modalTitle: null,
  491. form: this.$form.createForm(this),
  492. visible: false,
  493. // 下拉框map
  494. levelMap: {},
  495. periodTypeMap: {},
  496. unitMap: {},
  497. cdMap: {},
  498. ytMap: {},
  499. specialMap: {},
  500. spareTypeData: [],
  501. spareTypeDataMiddle: [],
  502. spareTypeDataChild: [],
  503. producers: [],
  504. ggList: [],
  505. headers: {
  506. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  507. },
  508. // 表头
  509. columns: [
  510. {
  511. title: '型号',
  512. dataIndex: 'model'
  513. },
  514. {
  515. title: '名称',
  516. dataIndex: 'name'
  517. },
  518. {
  519. title: '新号',
  520. dataIndex: 'no'
  521. },
  522. {
  523. title: '旧号',
  524. dataIndex: 'zbh'
  525. },
  526. {
  527. title: '更换周期',
  528. dataIndex: 'period',
  529. customRender: (text, record, index) => {
  530. return text + this.BaseTool.Table.getMapText(this.periodTypeMap, record.periodType)
  531. }
  532. },
  533. {
  534. title: '数量',
  535. dataIndex: 'num'
  536. },
  537. {
  538. title: '操作',
  539. key: 'action',
  540. checked: true,
  541. align: 'center',
  542. // fixed: 'right',
  543. scopedSlots: { customRender: 'action' }
  544. }
  545. ],
  546. data: [],
  547. sbId: null,
  548. image: '',
  549. selectedRowKeys: [],
  550. selectedRows: [],
  551. options: {
  552. rowSelection: {
  553. selectedRowKeys: this.selectedRowKeys
  554. }
  555. }
  556. }
  557. },
  558. props: {
  559. },
  560. created () {
  561. // 下拉框map
  562. this.setTree()
  563. this.specialMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  564. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_PART_INFO_LEVEL)
  565. this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
  566. this.cdMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.PRODUCER_AREA)
  567. this.ytMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SPARE_USE_TYPE)
  568. this.periodTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CHECK_PLAN_PERIOD_TYPE)
  569. },
  570. methods: {
  571. base (record, sbId) {
  572. this.visible = true
  573. this.sbId = sbId
  574. console.log('sbId: ', sbId)
  575. // 如果是空标识添加
  576. if (this.BaseTool.Object.isBlank(record)) {
  577. this.modalTitle = '添加'
  578. this.isAdd = true
  579. this.$refs.imageUpload.base(1, [])
  580. return
  581. }
  582. this.modalTitle = '编辑'
  583. if (this.BaseTool.Object.isBlank(record.id)) {
  584. this.modalTitle = '复制'
  585. }
  586. selectSbModelListBySpareId({ id: record.id }).then(res => {
  587. this.data = res.data
  588. })
  589. const { form: { setFieldsValue } } = this
  590. this.applicationFileList = record.applicationFileList
  591. this.defaultApplicationFileList = this.BaseTool.UPLOAD.transImg(this.applicationFileList)
  592. this.unitName = record.unit
  593. this.unitNameBz = record.unitBz
  594. this.gg = record.ggxh
  595. // 日期处理
  596. this.$nextTick(() => {
  597. setFieldsValue(Object.assign(pick(record, [
  598. 'id',
  599. 'no',
  600. 'sbId',
  601. 'initNo',
  602. 'uniteNo',
  603. 'nameNo',
  604. 'ggNo',
  605. 'name',
  606. 'parentTypeId',
  607. 'middleTypeId',
  608. 'childTypeId',
  609. 'typeId',
  610. 'level',
  611. 'initialValue',
  612. 'producerId',
  613. 'producerName',
  614. 'supplierId',
  615. 'supplierName',
  616. 'unit',
  617. 'unitBz',
  618. 'unitRate',
  619. 'englishName',
  620. 'childNo',
  621. 'parentNo',
  622. 'parentName',
  623. 'childName',
  624. 'typeName',
  625. 'middleNo',
  626. 'middleName',
  627. 'cd',
  628. 'ggxh',
  629. 'yt',
  630. 'zjm',
  631. 'isSpecial',
  632. 'zbh',
  633. 'agePeriod',
  634. 'usePeriod',
  635. 'purchasePeriod',
  636. 'maxStock',
  637. 'minStock',
  638. 'initStock',
  639. 'remark'
  640. ])))
  641. })
  642. this.image = record.image
  643. const fileList = []
  644. if (record.image) {
  645. fileList.push({
  646. uid: '-1',
  647. name: record.name,
  648. status: 'done',
  649. url: this.BaseTool.Constant.FILE_URL + record.image,
  650. originUrl: record.image
  651. })
  652. }
  653. this.$refs.imageUpload.base(1, fileList)
  654. },
  655. save () {
  656. const { form: { validateFieldsAndScroll, setFieldsValue } } = this
  657. this.confirmLoading = true
  658. console.log('sbId: ' + this.sbId)
  659. setFieldsValue({
  660. 'unit': this.unitName,
  661. 'unitBz': this.unitNameBz,
  662. 'sbId': this.sbId
  663. })
  664. validateFieldsAndScroll((errors, values) => {
  665. if (errors) {
  666. this.confirmLoading = false
  667. return
  668. }
  669. values.applicationFileList = this.applicationFileList
  670. values.detailList = this.data
  671. values.image = this.image
  672. // 日期处理
  673. if (this.BaseTool.String.isBlank(values.id)) {
  674. addSparePartInfo(values)
  675. .then(() => {
  676. this.handleCancel(values)
  677. }).catch(() => {
  678. this.confirmLoading = false
  679. })
  680. } else {
  681. updateSparePartInfo(values)
  682. .then(() => {
  683. this.handleCancel(values)
  684. }).catch(() => {
  685. this.confirmLoading = false
  686. })
  687. }
  688. })
  689. },
  690. handleProducerSelect () {
  691. this.$refs.producerSelectModal.base({}, { type: 3 })
  692. },
  693. handleProducerSelected (record, selectedRowKeys, selectedRow) {
  694. const { form: { setFieldsValue } } = this
  695. const [ key ] = selectedRowKeys
  696. const [ row ] = selectedRow
  697. setFieldsValue({
  698. 'producerId': key,
  699. 'producerName': row.name
  700. })
  701. },
  702. handleSupplierSelect () {
  703. this.$refs.supplierSelectModal.base()
  704. },
  705. handleSupplierSelected (record, selectedRowKeys, selectedRow) {
  706. const { form: { setFieldsValue } } = this
  707. const [ key ] = selectedRowKeys
  708. const [ row ] = selectedRow
  709. setFieldsValue({
  710. 'supplierId': key,
  711. 'supplierName': row.name
  712. })
  713. },
  714. handleCancel (values) {
  715. this.visible = false
  716. this.confirmLoading = false
  717. this.form.resetFields()
  718. this.unitName = null
  719. this.unitNameBz = null
  720. this.gg = null
  721. this.isAdd = true
  722. this.data = []
  723. if (this.BaseTool.Object.isNotBlank(values)) {
  724. this.$emit('ok', values)
  725. } else {
  726. this.$emit('ok')
  727. }
  728. },
  729. /**
  730. * 设置仓库、备件类别树
  731. */
  732. setTree () {
  733. fetchStoreTree().then(res => {
  734. this.storeTreeDate = this.BaseTool.TREE.treeFilter(res.data, (item) => {
  735. console.log(item.title + ',,' + item.level)
  736. if (item.level === this.DictCache.VALUE.STORE_LEVEL.ZONGCANG) {
  737. console.log(false)
  738. item.selectable = false
  739. item.disabled = true
  740. }
  741. })
  742. })
  743. fetchSpareTypeTree().then(res => {
  744. this.spareTypeData = res.data
  745. })
  746. /* querySpareType({ filter: 2, parentId: record.parentTypeId }).then(res => {
  747. this.spareTypeDataMiddle = res.data
  748. })
  749. querySpareType({ filter: 2, parentId: record.middleTypeId }).then(res => {
  750. this.spareTypeDataChild = res.data
  751. }) */
  752. fetchSbGuigeOptions().then(res => {
  753. this.ggList = res.data
  754. })
  755. },
  756. catchImage (fileList) {
  757. if (fileList.length !== 0) {
  758. this.image = fileList[0].url
  759. }
  760. },
  761. checkSpareNo () {
  762. const { form: { getFieldValue } } = this
  763. const typeId = getFieldValue('typeId')
  764. const name = getFieldValue('name')
  765. // const ggxh = getFieldValue('ggxh')
  766. if (typeId == null) {
  767. this.$message.error('请先设置大小类型')
  768. return
  769. }
  770. querySparePartInfo({
  771. typeId: typeId,
  772. name: name,
  773. dataScope: {
  774. sortBy: 'desc',
  775. sortName: 'name'
  776. }
  777. }).then(res => {
  778. this.data = res.data
  779. })
  780. },
  781. /**
  782. * @function 任务类型文本框的值变化时的回调
  783. * @author ***
  784. * @time 2020-08-17
  785. **/
  786. handleSearch (value) {
  787. this.handleChange(value)
  788. },
  789. /**
  790. * @function 任务类型改变时的回调
  791. * @author ***
  792. * @time 2020-08-17
  793. **/
  794. handleChange (value) {
  795. this.unitName = (!isNaN(value) && value !== '') ? this.BaseTool.Object.getField(this.unitMap, value) : value
  796. if (isNaN(this.unitName) || this.unitName === '') {
  797. this.unitName = value
  798. }
  799. },
  800. /**
  801. * @function 修改设备关联
  802. * @author ***
  803. * @time 2020-08-17
  804. **/
  805. handleDetailSelect (record) {
  806. const modal = this.$refs.baseModal
  807. modal.base(record)
  808. },
  809. handleDetailSelected (values) {
  810. const newData = [...this.data]
  811. for (let j = 0; j < newData.length; j++) {
  812. if (values.sbId === newData[j].sbId) {
  813. newData[j].num = values.num
  814. newData[j].period = values.period
  815. newData[j].periodType = values.periodType
  816. break
  817. }
  818. }
  819. this.data = newData
  820. },
  821. /**
  822. * @function 添加关联设备
  823. * @author ***
  824. * @time 2020-08-17
  825. **/
  826. handleSbSelect () {
  827. const modal = this.$refs.sbInfoSelectModal
  828. modal.base()
  829. },
  830. handleSbSelected (keys, rows) {
  831. const { data } = this
  832. for (let i = 0; i < rows.length; i++) {
  833. var find = false
  834. for (let j = 0; j < data.length; j++) {
  835. if (rows[i].id === data[j].sbId) {
  836. find = true
  837. break
  838. }
  839. }
  840. if (!find) {
  841. const sbId = rows[i].id
  842. const selectData = rows[i]
  843. selectData.num = 1
  844. selectData.sbId = sbId
  845. selectData.id = null
  846. selectData.period = 1
  847. selectData.periodType = 1
  848. data.push(selectData)
  849. }
  850. }
  851. },
  852. /**
  853. * @function 任务类型失焦事件
  854. * @author ***
  855. * @time 2020-08-17
  856. **/
  857. handleBlur (value) {
  858. this.unitName = value
  859. },
  860. /**
  861. * @function 任务类型文本框的值变化时的回调
  862. * @author ***
  863. * @time 2020-08-17
  864. **/
  865. handleSearchBz (value) {
  866. this.handleChange(value)
  867. },
  868. /**
  869. * @function 任务类型改变时的回调
  870. * @author ***
  871. * @time 2020-08-17
  872. **/
  873. handleChangeBz (value) {
  874. this.unitNameBz = (!isNaN(value) && value !== '') ? this.BaseTool.Object.getField(this.unitMap, value) : value
  875. if (isNaN(this.unitNameBz) || this.unitNameBz === '') {
  876. this.unitNameBz = value
  877. }
  878. },
  879. /**
  880. * @function 任务类型失焦事件
  881. * @author ***
  882. * @time 2020-08-17
  883. **/
  884. handleBlurBz (value) {
  885. this.unitNameBz = value
  886. },
  887. /**
  888. * @function 任务类型文本框的值变化时的回调
  889. * @author ***
  890. * @time 2020-08-17
  891. **/
  892. handleSearchG (value) {
  893. this.handleChangeG(value)
  894. },
  895. /**
  896. * @function 任务类型改变时的回调
  897. * @author ***
  898. * @time 2020-08-17
  899. **/
  900. handleChangeG (value) {
  901. this.gg = (!isNaN(this.ggList[value]) && this.ggList[value] !== '') ? this.ggList[value].label : value
  902. if (isNaN(this.gg) || this.gg === '') {
  903. this.gg = value
  904. }
  905. },
  906. handleStoreSelect () {
  907. this.$refs.storeSelectModal.base()
  908. },
  909. handleStoreSelected (record, keys, rows) {
  910. const [ key ] = keys
  911. const [ row ] = rows
  912. const { form: { setFieldsValue } } = this
  913. // 日期处理
  914. this.$nextTick(() => {
  915. setFieldsValue(Object.assign({
  916. 'storeId': key,
  917. 'storeName': row.name
  918. }))
  919. })
  920. },
  921. handleDel (id) {
  922. const data = [...this.data]
  923. if (this.selectedRowKeys.length === 0) {
  924. this.$message.error('请至少选择一条数据')
  925. return
  926. }
  927. this.data = data.filter(item => !this.selectedRowKeys.includes(item.id))
  928. },
  929. handleDelOne (id) {
  930. const data = [...this.data]
  931. this.data = data.filter(item => id !== item.id)
  932. },
  933. /**
  934. * @function 任务类型失焦事件
  935. * @author ***
  936. * @time 2020-08-17
  937. **/
  938. handleBlurG (value) {
  939. this.gg = value
  940. },
  941. parentChange (val, option) {
  942. querySpareType({ parentId: val, filter: 2 }).then(res => {
  943. this.spareTypeDataMiddle = res.data
  944. })
  945. const { form: { setFieldsValue } } = this
  946. setFieldsValue({ parentNo: option.data.key, typeId: val, middleTypeId: null, middleNo: null, childTypeId: null, childNo: null })
  947. },
  948. middleChange (val, option) {
  949. querySpareType({ parentId: val, filter: 2 }).then(res => {
  950. this.spareTypeDataChild = res.data
  951. })
  952. const { form: { setFieldsValue } } = this
  953. setFieldsValue({ middleNo: option.data.key, typeId: val, childTypeId: null, childNo: null })
  954. },
  955. childChange (val, option) {
  956. const { form: { setFieldsValue } } = this
  957. setFieldsValue({ childNo: option.data.key, typeId: val, childTypeId: val })
  958. },
  959. handleApplicationFileChange (info) {
  960. this.defaultApplicationFileList = info.fileList
  961. this.applicationFileList = this.setFileList(info, 14)
  962. },
  963. setFileList (info, type) {
  964. const file = info.file
  965. const fileList = info.fileList
  966. if (file.status === 'done') {
  967. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  968. } else if (file.status === 'removed') {
  969. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  970. } else if (file.status === 'error') {
  971. this.$message.error('上传失败')
  972. return []
  973. }
  974. }
  975. }
  976. }
  977. </script>