sparepart.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. <template>
  2. <view>
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="申请备品备件"
  8. @clickLeft="back"
  9. ></uni-nav-bar>
  10. <view class="sparepart-container">
  11. <view class="infos">
  12. <u-form
  13. labelPosition="left"
  14. :model="formData"
  15. ref="formRef"
  16. labelWidth="250"
  17. labelAlign="left"
  18. class="baseForm"
  19. >
  20. <u-form-item
  21. label="仓库:"
  22. prop="warehouseId"
  23. style="height: 120rpx"
  24. required
  25. >
  26. <picker
  27. @change="bindPickerChange"
  28. :value="warehosueVal"
  29. :range="warehouseList"
  30. range-key="name"
  31. >
  32. <input
  33. disabled
  34. class="uni-input"
  35. v-model="warehosueName"
  36. placeholder="请选择"
  37. />
  38. </picker>
  39. </u-form-item>
  40. <!-- <u-form-item
  41. label="期望完成时间:"
  42. prop="approvalUserId"
  43. style="height: 120rpx"
  44. >
  45. <text class="content" @click="timeShow = true">{{
  46. formData.expectedPerformanceTime | timeFilter
  47. }}</text>
  48. </u-form-item> -->
  49. </u-form>
  50. </view>
  51. <view class="detail-title">
  52. 申请明细
  53. <u-button @click="addGoods" type="success" size="small">
  54. 添加物品
  55. </u-button>
  56. <u-button @click="addCurrGoods" type="success" size="small">
  57. 绑定备件
  58. </u-button>
  59. </view
  60. >
  61. <view class="detail-content">
  62. <uni-collapse
  63. :key="forceUpdate"
  64. ref="collapseRef"
  65. v-model="collapseVal"
  66. accordion
  67. >
  68. <uni-collapse-item
  69. :typeOpen="1"
  70. :name="item.informationCode"
  71. :show-animation="true"
  72. v-for="(item, index) in registerlist"
  73. :key="item.informationCode"
  74. >
  75. <template slot="title">
  76. <view class="row">
  77. <view class="col">
  78. <view class="col-item">
  79. {{ item.informationName }}({{ item.informationCode }})
  80. </view>
  81. </view>
  82. <view class="col">
  83. <view class="col-item">
  84. 规格/型号:{{ item.specification }}/{{ item.modelType }}
  85. </view>
  86. <view class="col-item">
  87. {{ item.isUnpack ? '包装单位' : '单位' }}:{{
  88. item.isUnpack
  89. ? `${item.minPackUnit || ''}`
  90. : item.measuringUnit
  91. }}
  92. </view>
  93. </view>
  94. <view class="col">
  95. <view class="col-item">
  96. 所需数量:{{ item.selectNum || 0
  97. }}{{ item.measuringUnit }}/{{ item.num
  98. }}{{ item.measuringUnit }}
  99. </view>
  100. <view
  101. class="col-item text-primary"
  102. @click.stop="openPlus(item)"
  103. >
  104. 添加备品备件
  105. </view>
  106. </view>
  107. </view>
  108. </template>
  109. <view class="instance-list">
  110. <view class="" v-for="(itm, index) in item.tableData">
  111. <view class="row">
  112. <uni-icons
  113. type="trash"
  114. size="27"
  115. color="red"
  116. @click="handleDelete(item, itm, index)"
  117. ></uni-icons>
  118. <view class="col">
  119. <view class="col-item">
  120. {{ itm.onlyCode }}
  121. </view>
  122. </view>
  123. <view class="col">
  124. <view class="col-item"> 批次号:{{ itm.batchNum }} </view>
  125. <view class="col-item"> 包装编码:{{ itm.num }} </view>
  126. </view>
  127. <view class="col">
  128. <view class="col-item">
  129. {{ itm.manufactureTime ? '生产日期' : '采购日期' }}:{{
  130. itm.manufactureTime || itm.procurementTime
  131. }}
  132. </view>
  133. </view>
  134. <view class="col" v-if="!itm.isUnpack">
  135. <view class="col-item">
  136. 最小包装单元:{{ itm.measurementUnit }}{{ itm.unit }}/{{
  137. itm.minPackUnit
  138. }}
  139. </view>
  140. </view>
  141. <view class="col">
  142. <view class="col-item">
  143. 货位:{{ itm.warehouseName }}-{{ itm.areaName }}-{{
  144. itm.shelfCode
  145. }}-{{ itm.cargoSpaceCode }}
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. </uni-collapse-item>
  152. </uni-collapse>
  153. <!-- <view class="col" v-for="(item, index) in registerlist" :key="item.id">
  154. <view>
  155. <view>{{ item.informationName }}</view>
  156. <view style="color: #aaaaaa"
  157. >({{ item.informationCode }}/{{ item.modelType }})</view
  158. >
  159. </view>
  160. <u-number-box
  161. v-model="item.num"
  162. :step="1"
  163. :min="0"
  164. :name="index"
  165. :disabledInput="true"
  166. @change="numChange"
  167. ></u-number-box>
  168. </view>
  169. <view class="plus" @click="openPlus">+</view> -->
  170. </view>
  171. </view>
  172. <view class="sparepart-footer">
  173. <button class="primary" @click="toSubmit">提交</button>
  174. <button class="defualt" @click="back">返回</button>
  175. </view>
  176. <u-datetime-picker
  177. @confirm="timeConfirm"
  178. @cancel="timeCancel"
  179. :show="timeShow"
  180. v-model="formData.expectedPerformanceTime"
  181. mode="datetime"
  182. ></u-datetime-picker>
  183. <u-popup :show="popShow" @close="close" @open="open">
  184. <view class="select-container" v-if="popShow">
  185. <view class="title"
  186. >添加备件
  187. <view class="btn-box">
  188. <text class="btn cancel" @click="close">取消</text>
  189. <text class="btn confirm" @click="popConfirm">确定</text>
  190. </view>
  191. </view>
  192. <!-- <input
  193. type="text"
  194. :value="curClassification.name"
  195. placeholder="选择分类"
  196. @click="openPicker"
  197. /> -->
  198. <input
  199. type="text"
  200. @input="nameFilter"
  201. v-model="searchKey"
  202. placeholder="搜索编号"
  203. />
  204. <view class="self-table-header">
  205. <view class="table-code">备品备件编码</view>
  206. <view class="table-batch">批次号</view>
  207. </view>
  208. <view class="table-wrapper">
  209. <view class="listContent">
  210. <checkbox-group @change="selectionChange">
  211. <view
  212. class="listBox"
  213. v-for="(item, index) in tableData"
  214. :key="index"
  215. >
  216. <label>
  217. <view class="self-table-tr">
  218. <view class="table-code">{{ item.onlyCode }}</view>
  219. <view class="table-batch">{{ item.batchNum }}</view>
  220. <view class="table-date"></view>
  221. <view class="other-info">
  222. <view>包装编码:{{ item.num }}</view>
  223. <view v-if="!currentRow.isUnpack"
  224. >最小包装单元:{{ item.measurementUnit
  225. }}{{ item.unit }}/{{ item.minPackUnit }}</view
  226. >
  227. <view v-if="item.manufactureTime || item.procurementTime"
  228. >{{
  229. item.procurementTime ? '采购日期' : '生产日期'
  230. }}:{{
  231. item.manufactureTime || item.procurementTime
  232. }}</view
  233. >
  234. <view style="width: 100%"
  235. >货位:{{ item.warehouseName }}-{{ item.areaName }}-{{
  236. item.shelfCode
  237. }}-{{ item.cargoSpaceCode }}</view
  238. >
  239. </view>
  240. <view class="checked">
  241. <checkbox
  242. :value="item.onlyCode"
  243. :checked="selectList.includes(item.onlyCode)"
  244. ></checkbox>
  245. </view>
  246. </view>
  247. </label>
  248. </view>
  249. </checkbox-group>
  250. <u-empty style="margin-top: 20vh" v-if="!tableData.length" />
  251. </view>
  252. </view>
  253. </view>
  254. </u-popup>
  255. <!-- <ba-tree-picker
  256. ref="treePicker"
  257. :multiple="false"
  258. @select-change="confirm"
  259. title="选择分类"
  260. :localdata="listData"
  261. valueKey="id"
  262. textKey="name"
  263. childrenKey="children"
  264. /> -->
  265. <ba-tree-picker
  266. ref="verifyTreePicker"
  267. key="verify"
  268. :multiple="false"
  269. @select-change="verifyDeptConfirm"
  270. title="选择部门"
  271. :localdata="deptList"
  272. valueKey="code"
  273. textKey="name"
  274. childrenKey="children"
  275. />
  276. <u-modal
  277. :show="showConfirm"
  278. title="提示"
  279. @confirm="warehosueConfirm"
  280. @cancel="warehosueCancel"
  281. :showCancelButton="true"
  282. content="仓库修改后,已添加的备品备件信息将会被清空,是否要继续修改仓库?"
  283. ></u-modal>
  284. </view>
  285. </template>
  286. <script>
  287. import { get, postJ, post } from '@/utils/api.js'
  288. import dayjs from 'dayjs'
  289. import { debounce } from 'lodash'
  290. let [page, size, isEnd] = [1, 10, true]
  291. export default {
  292. components: {},
  293. filters: {
  294. timeFilter (inp) {
  295. return inp && dayjs(inp).format('YYYY-MM-DD HH:mm')
  296. }
  297. },
  298. data () {
  299. return {
  300. workOrderId: '',
  301. planFinishTime: '',
  302. workOrderCode: '',
  303. showConfirm: false,
  304. popShow: false,
  305. timeShow: false,
  306. time: '',
  307. pageId: '',
  308. pickerDeptShow: false,
  309. list: [],
  310. treeList: [],
  311. classificationId: '',
  312. // formData: {
  313. // applyOrder: getRuleNo('BJ'),
  314. // expectedPerformanceTime: new Date().getTime()
  315. // },
  316. registerlist: [],
  317. listData: [],
  318. curClassification: {
  319. id: '',
  320. name: ''
  321. },
  322. planCode: '',
  323. formData: {
  324. approvalUserId: '',
  325. approvalUserName: '',
  326. verifyDeptCode: '',
  327. verifyDeptName: ''
  328. // expectedPerformanceTime: new Date().getTime()
  329. },
  330. pickerIndex: 0,
  331. userList: [],
  332. deptList: [], //部门
  333. searchKey: '',
  334. tableData: [],
  335. selectIndex: [],
  336. chooseItem: {},
  337. sourceCode: null,
  338. sourceId: null,
  339. // 关键词搜索
  340. nameFilter: debounce(this.getTableData, 500),
  341. chooseIndex: null,
  342. warehouseId: '',
  343. warehosueName: '',
  344. warehouseList: [],
  345. memo: [],
  346. planList: [],
  347. selectList: [],
  348. currentRow: {},
  349. forceUpdate: false,
  350. warehosueVal: 0,
  351. collapseVal: ''
  352. }
  353. },
  354. onLoad (options) {
  355. this.planCode = options.planCode
  356. this.sourceCode = options.sourceCode
  357. this.sourceId = options.sourceId
  358. this.getDept()
  359. this._getPlanInfo()
  360. this.getwarehouseList()
  361. // this.workOrderId = workOrderId
  362. // this.workOrderCode = workOrderCode
  363. // this.planFinishTime = planFinishTime
  364. // this._getClassification()
  365. },
  366. computed: {
  367. selectAll: {
  368. set (val) {
  369. if (val) {
  370. this.selectList = this.tableData.map(i => i.onlyCode)
  371. } else {
  372. this.selectList = []
  373. }
  374. },
  375. get () {
  376. return (
  377. this.selectList.length &&
  378. this.selectList.length == this.tableData.length
  379. )
  380. }
  381. }
  382. },
  383. onShow () {
  384. uni.$off('setSelectList')
  385. uni.$on('setSelectList', selectList => {
  386. if (selectList?.length) {
  387. this.registerlist = this.registerlist.filter(item => {
  388. const index = selectList.findIndex(i => i.curId === item.curId)
  389. if (index > -1) {
  390. selectList.splice(index, 1)
  391. }
  392. return index > -1
  393. })
  394. this.registerlist.push(
  395. ...selectList.map(item => {
  396. return {
  397. curId: item.curId,
  398. isUnpack: item.isUnpack,
  399. informationCode: item.assetCode || item.informationCode,
  400. informationName: item.assetName || item.informationName,
  401. specification: item.specification,
  402. minPackUnit: item.minPackUnit,
  403. modelType: item.modelType,
  404. measuringUnit: item.unit || item.measuringUnit,
  405. tableData: item.tableData || [],
  406. num: 0,
  407. selectNum: 0
  408. }
  409. })
  410. )
  411. }
  412. })
  413. },
  414. onReachBottom: function () {
  415. if (isEnd) {
  416. return
  417. }
  418. // 显示加载图标
  419. uni.showLoading({
  420. title: '数据加载中'
  421. })
  422. this.getMoreLists()
  423. },
  424. methods: {
  425. // 选择审核人确定
  426. handlePicker (e, list, idKey, nameKey) {
  427. if (idKey) {
  428. this.formData[idKey] = list[e?.detail.value]?.id
  429. }
  430. if (nameKey) {
  431. this.formData[nameKey] = list[e?.detail.value]?.name
  432. }
  433. this.$nextTick(() => {
  434. if (idKey === 'assetType' || idKey === 'bizScene') {
  435. this.$refs.formRef.validateField(idKey)
  436. }
  437. })
  438. },
  439. // 部门确认
  440. verifyDeptConfirm (data, name) {
  441. this.formData.verifyDeptCode = data[0]
  442. this.formData.verifyDeptName = name
  443. this.formData.approvalUserId = ''
  444. this.formData.approvalUserName = ''
  445. this.getUser(data[0])
  446. },
  447. // 获取部门
  448. getDept () {
  449. get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  450. if (res?.success) {
  451. this.deptList = res.data
  452. }
  453. })
  454. },
  455. // 获取人员
  456. getUser (deptCode) {
  457. post(this.apiUrl + '/main/user/list', {
  458. deptCode,
  459. page: 1,
  460. size: 9999
  461. }).then(res => {
  462. if (res?.success) {
  463. this.userList = res.data.items.map(item => {
  464. item.name = item.trueName
  465. item.id = item.userId
  466. return item
  467. })
  468. }
  469. })
  470. },
  471. numChange (val) {
  472. if (val?.value === 0) {
  473. this.registerlist.splice(val.name, 1)
  474. }
  475. },
  476. back () {
  477. uni.navigateBack({
  478. delta: 1
  479. })
  480. },
  481. selectionChange ({ detail }) {
  482. this.selectList = detail.value
  483. },
  484. // 点击提交
  485. toSubmit () {
  486. // if (!this.formData.expectedPerformanceTime) {
  487. // uni.showToast({
  488. // icon: 'error',
  489. // title: '请选择期望完成时间'
  490. // })
  491. // return
  492. // }
  493. // if (!this.formData.approvalUserName) {
  494. // uni.showToast({
  495. // icon: 'error',
  496. // title: '请选择审核人'
  497. // })
  498. // return
  499. // }
  500. const stockOutApplyDetailList = this.registerlist.filter(
  501. i => i.tableData.length
  502. )
  503. if (!stockOutApplyDetailList.length) {
  504. uni.showToast({
  505. icon: 'error',
  506. title: '请添加申请备件'
  507. })
  508. return
  509. }
  510. const params = {
  511. ...this.formData,
  512. sparePartsApplyDetailList: this.registerlist
  513. .filter(i => i.tableData.length)
  514. .map(i => i.tableData)
  515. .flat()
  516. .map(i => {
  517. delete i.id
  518. return {
  519. informationCode: i.assetCode,
  520. informationName: i.assetName,
  521. assetCode: i.onlyCode
  522. }
  523. }),
  524. sourceCode: this.sourceCode,
  525. sourceId: this.sourceId,
  526. sourceType: 1
  527. }
  528. params.expectedPerformanceTime = dayjs(
  529. params.expectedPerformanceTime
  530. ).format('YYYY-MM-DD HH:mm:ss')
  531. postJ(this.apiUrl + '/sparePartsApply/save', params).then(res => {
  532. if (res?.success) {
  533. this.back()
  534. }
  535. })
  536. },
  537. addGoods () {
  538. if (!this.warehouseId) {
  539. uni.showToast({
  540. title: '请选择仓库!',
  541. icon: 'none'
  542. })
  543. return
  544. }
  545. const storageKey = Date.now() + ''
  546. uni.setStorageSync(storageKey, this.registerlist)
  547. uni.navigateTo({
  548. url:
  549. '/pages/warehouse/outHouse/selectOutType?warehousingType=7&warehousingName=备品备件' +
  550. '&storageKey=' +
  551. storageKey +
  552. '&warehouseId=' +
  553. this.warehouseId
  554. })
  555. },
  556. addCurrGoods () {
  557. const storageKey = Date.now() + ''
  558. uni.setStorageSync(storageKey, this.registerlist)
  559. uni.navigateTo({
  560. url:
  561. '/pages/warehouse/outHouse/selectCurSarepart?workOrderCode=' +this.sourceCode +
  562. '&storageKey=' +
  563. storageKey +
  564. '&warehouseId=' +
  565. this.warehouseId
  566. })
  567. },
  568. handleDelete (item, row, index) {
  569. uni.showModal({
  570. title: `确定删除${row.onlyCode}?`,
  571. content: '',
  572. confirmText: '确认',
  573. success: function (res) {
  574. if (res.confirm) {
  575. item.tableData.splice(index, 1)
  576. const obj = this.planList.find(i => i.curId === item.curId)
  577. item.selectNum = item.tableData.reduce((next, pre) => {
  578. next += pre.isUnpack ? 1 : pre.measurementUnit || 0
  579. return next
  580. }, 0)
  581. if (!obj) {
  582. // 非计划
  583. item.num = item.selectNum
  584. }
  585. }
  586. }
  587. })
  588. },
  589. // 选择备品备件
  590. openPicker () {
  591. this.$refs.treePicker._show()
  592. },
  593. handleSelectionChange (val) {
  594. console.log('handleSelectionChangeval', val)
  595. this.selectIndex = val.detail.index
  596. },
  597. //获取备品备件分类
  598. _getClassification () {
  599. postJ(this.apiUrl + '/classificationTree/list', [4]).then(res => {
  600. if (res?.success) {
  601. this.listData = res.data
  602. }
  603. })
  604. },
  605. // 查询计划备件明细
  606. _getPlanInfo () {
  607. postJ(this.apiUrl + '/sparePartsApply/getSparePartsApplyDetail', {
  608. planCode: this.planCode
  609. }).then(res => {
  610. if (res?.success) {
  611. this.registerlist = res.data.map(item => {
  612. item.tableData = []
  613. item.selectNum = 0
  614. item.curId = item.informationCode
  615. delete item.equipmentCode
  616. return item
  617. })
  618. this.planList = uni.$u.deepClone(this.registerlist)
  619. }
  620. })
  621. },
  622. close () {
  623. this.selectIndex = []
  624. // this.$refs.tableRef.clearSelection()
  625. this.popShow = false
  626. this.chooseItem = {}
  627. this.currentRow = {}
  628. },
  629. // 确定选择的备品备件
  630. popConfirm () {
  631. const selectList = [
  632. ...this.memo,
  633. ...this.tableData.filter(item =>
  634. this.selectList.includes(item.onlyCode)
  635. )
  636. ]
  637. if (!selectList.length) {
  638. uni.showToast({
  639. icon: 'none',
  640. title: '请选择需添加的备品备件'
  641. })
  642. return
  643. }
  644. // this.registerlist.push(this.chooseItem)
  645. this.currentRow.tableData = selectList
  646. const obj = this.planList.find(i => i.curId === this.currentRow.curId)
  647. let selectNum = 0
  648. this.currentRow.tableData.forEach(item => {
  649. selectNum += item.isUnpack ? 1 : item.measurementUnit || 0
  650. })
  651. this.currentRow.selectNum = selectNum
  652. if (!obj) {
  653. // 非计划
  654. this.currentRow.num = this.currentRow.selectNum
  655. }
  656. this.collapseVal = this.currentRow.informationCode
  657. console.log(this.collapseVal)
  658. this.close()
  659. },
  660. open (...args) {
  661. // this.getTableData()
  662. },
  663. //获取仓库
  664. getwarehouseList () {
  665. post(this.apiUrl + '/warehouseGoodsshelves/select/warehouseList').then(
  666. res => {
  667. if (res.success) {
  668. this.warehouseList = res.data
  669. .filter(i => !i.isDelete && !!i.status)
  670. .map(n => {
  671. return {
  672. name: n.name,
  673. id: n.id
  674. }
  675. })
  676. }
  677. }
  678. )
  679. },
  680. warehosueConfirm () {
  681. const obj = this.warehouseList[this.warehouseInfo?.detail?.value] || {}
  682. this.warehosueName = obj.name
  683. this.warehouseId = obj.id
  684. this.registerlist = uni.$u.deepClone(this.planList)
  685. this.showConfirm = false
  686. },
  687. warehosueCancel () {
  688. this.warehosueVal = this.warehouseList.findIndex(
  689. i => i.id === this.warehouseId
  690. )
  691. this.showConfirm = false
  692. },
  693. bindPickerChange (val) {
  694. this.warehosueVal = val?.detail?.value
  695. if (
  696. this.warehouseId &&
  697. (this.registerlist.length > this.planList.length ||
  698. this.registerlist.some(i => i.tableData.length))
  699. ) {
  700. this.showConfirm = true
  701. this.warehouseInfo = val
  702. } else {
  703. const obj = this.warehouseList[val?.detail?.value] || {}
  704. this.warehosueName = obj.name
  705. this.warehouseId = obj.id
  706. this.registerlist = uni.$u.deepClone(this.planList)
  707. }
  708. },
  709. getTableData () {
  710. const params = {
  711. assetCode: this.currentRow.informationCode,
  712. searchKey: this.searchKey,
  713. warehouseId: this.warehouseId
  714. }
  715. this.memo.push(
  716. ...this.tableData.filter(item =>
  717. this.selectList.includes(item.onlyCode)
  718. )
  719. )
  720. this.selectList = []
  721. get(
  722. this.apiUrl + '/outInWarehouse/getWarehouseActualDetail',
  723. params
  724. ).then(res => {
  725. if (res?.success) {
  726. this.tableData = res.data
  727. this.$nextTick(() => {
  728. this.tableData.map((i, idx) => {
  729. const index = this.memo.findIndex(
  730. itm => i.onlyCode === itm.onlyCode
  731. )
  732. if (index > -1) {
  733. // this.$refs.tableRef.toggleRowSelection(idx, true)
  734. this.selectList.push(i.onlyCode)
  735. this.memo.splice(index, 1)
  736. }
  737. })
  738. })
  739. }
  740. })
  741. },
  742. // 备品备件行选中事件
  743. rowclick (item, index) {
  744. this.chooseIndex = index
  745. this.selectIndex = [index]
  746. this.chooseItem = item
  747. },
  748. openPlus (item) {
  749. if (!this.warehouseId) {
  750. uni.showToast({
  751. title: '请选择仓库!',
  752. icon: 'none'
  753. })
  754. return
  755. }
  756. this.selectList = []
  757. this.memo = uni.$u.deepClone(item.tableData)
  758. this.currentRow = item
  759. this.popShow = true
  760. this.getTableData()
  761. },
  762. timeConfirm () {
  763. this.timeShow = false
  764. },
  765. timeCancel () {
  766. this.timeShow = false
  767. },
  768. resetEqui () {
  769. this.pickerDeptShow = true
  770. this.$refs.pickerDeptName.show()
  771. },
  772. handleChange (e) {
  773. let data = e.detail.value[e.detail.value.length - 1]
  774. this.classificationId = data.value
  775. page = 1
  776. isEnd = true
  777. uni.showLoading({
  778. title: '数据加载中'
  779. })
  780. this.getList()
  781. },
  782. getTreeList () {
  783. postJ(this.apiUrl + '/classificationTree/list', [4]).then(res => {
  784. // console.log(res)
  785. if (res.success) {
  786. this.treeList = res.data
  787. this.pickerDeptShow = true
  788. this.$refs.pickerDeptName.show()
  789. }
  790. })
  791. },
  792. getFirstList: function () {
  793. page = 1
  794. isEnd = true
  795. uni.showLoading({
  796. title: '数据加载中'
  797. })
  798. this.getList()
  799. },
  800. getMoreLists: function () {
  801. //获取更多数据
  802. page++
  803. this.getList()
  804. },
  805. //获取列表数据
  806. getList () {
  807. post(this.apiUrl + '/classificationSpareParts/classificationSpare/list', {
  808. page,
  809. size,
  810. code: '',
  811. classificationId: this.classificationId
  812. })
  813. .then(res => {
  814. // console.log(res)
  815. let data = res.data.records
  816. let pageTotal = res.data.pages
  817. if (page === 1) {
  818. data.forEach(el => {
  819. el.num = 0
  820. })
  821. this.list = data
  822. } else {
  823. data.forEach(element => {
  824. element.num = 0
  825. this.list.push(element)
  826. })
  827. }
  828. page < pageTotal ? (isEnd = false) : (isEnd = true)
  829. })
  830. .then(() => {
  831. uni.hideLoading()
  832. })
  833. },
  834. submit (data) {
  835. let list = data
  836. let pickData = list.filter(item => {
  837. return item.checked && !item.disabled && item.num > 0
  838. })
  839. if (pickData.length == 0) {
  840. uni.showToast({
  841. title: '请选择备品备件数量',
  842. icon: 'none',
  843. duration: 2000
  844. })
  845. return
  846. }
  847. this.$store.dispatch('maintenance/setSparepartIndex', this.index)
  848. this.$store.dispatch('maintenance/setSparepart', pickData)
  849. this.$store.dispatch('maintenance/setEquiIndex', this.equiIndex)
  850. this.back()
  851. }
  852. }
  853. }
  854. </script>
  855. <style lang="scss" scoped>
  856. .instance-list {
  857. background-color: #fff;
  858. font-size: 28rpx;
  859. .row {
  860. position: relative;
  861. padding: 10rpx 20rpx;
  862. & + .row {
  863. margin-top: 10rpx;
  864. }
  865. .uni-icons {
  866. position: absolute;
  867. top: 10rpx;
  868. right: 20rpx;
  869. }
  870. }
  871. }
  872. /deep/.uni-data-tree-input {
  873. display: none;
  874. }
  875. .no_data {
  876. position: fixed;
  877. top: 50%;
  878. left: 50%;
  879. transform: translate(-50%, -50%);
  880. .center {
  881. text-align: center;
  882. color: #555;
  883. font-size: $uni-font-size-base;
  884. }
  885. }
  886. .footer {
  887. position: fixed;
  888. display: flex;
  889. justify-content: space-between;
  890. align-items: center;
  891. bottom: 0;
  892. width: 100%;
  893. height: 90rpx;
  894. text-align: center;
  895. border-top: 1rpx solid #eeecec;
  896. background-color: #ffffff;
  897. .bottom {
  898. font-size: $uni-font-size-lg;
  899. margin-left: 20rpx;
  900. .select-all {
  901. color: $j-primary-green;
  902. }
  903. }
  904. .footer-span-btn {
  905. height: 30rpx;
  906. line-height: 30rpx;
  907. font-size: $uni-font-size-lg;
  908. color: #ffffff;
  909. margin-right: 20rpx;
  910. padding: 10rpx 20rpx;
  911. text-align: center;
  912. background-color: $j-primary-green;
  913. border-radius: 40rpx;
  914. }
  915. }
  916. .footer-right {
  917. justify-content: flex-end;
  918. }
  919. .sparepart-container {
  920. padding: 40rpx 20rpx;
  921. margin-bottom: 120rpx;
  922. .infos {
  923. border: 1rpx solid rgba(242, 242, 242, 1);
  924. padding: 0 20rpx;
  925. .col {
  926. height: 60rpx;
  927. line-height: 60rpx;
  928. display: flex;
  929. align-items: stretch;
  930. font-size: 28rpx;
  931. & + .col {
  932. margin-top: 4rpx;
  933. }
  934. .label {
  935. display: inline-block;
  936. width: 200rpx;
  937. padding-right: 20rpx;
  938. text-align: right;
  939. background-color: rgba(215, 215, 215, 1);
  940. }
  941. .content {
  942. flex: 1;
  943. background-color: rgba(242, 242, 242, 1);
  944. padding-left: 8rpx;
  945. border: 1rpx solid rgba(215, 215, 215, 1);
  946. }
  947. }
  948. }
  949. .detail-title {
  950. font-size: 34rpx;
  951. padding: 20rpx 0;
  952. margin-top: 10rpx;
  953. display: flex;
  954. justify-content: space-between;
  955. .u-button {
  956. width: 180rpx;
  957. margin: 0;
  958. }
  959. }
  960. .detail-content {
  961. border: 1rpx solid rgba(242, 242, 242, 1);
  962. min-height: 50vh;
  963. padding-bottom: 100rpx;
  964. .col {
  965. font-size: 30rpx;
  966. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  967. display: flex;
  968. padding: 10rpx;
  969. align-items: center;
  970. justify-content: space-between;
  971. background-color: rgba(242, 242, 242, 0.372549019607843);
  972. }
  973. .plus {
  974. width: 40rpx;
  975. height: 40rpx;
  976. line-height: 38rpx;
  977. text-align: center;
  978. background-color: $j-primary-border-green;
  979. color: #fff;
  980. margin: 16rpx 0 0 16rpx;
  981. }
  982. }
  983. /deep/.u-number-box {
  984. .u-number-box__minus,
  985. .u-number-box__plus,
  986. .u-number-box__input {
  987. font-size: 30rpx;
  988. height: 1.6em !important;
  989. }
  990. .u-number-box__input {
  991. width: 2em !important;
  992. }
  993. .u-number-box__minus,
  994. .u-number-box__plus {
  995. background-color: $j-primary-border-green !important;
  996. .u-icon__icon {
  997. color: #fff !important;
  998. }
  999. }
  1000. }
  1001. }
  1002. .select-container {
  1003. // height:60vh;
  1004. .title {
  1005. height: 70rpx;
  1006. line-height: 70rpx;
  1007. text-align: center;
  1008. background-color: $j-primary-border-green;
  1009. font-weight: bold;
  1010. position: relative;
  1011. font-size: 28rpx;
  1012. color: #fff;
  1013. .btn-box {
  1014. position: absolute;
  1015. top: 50%;
  1016. right: 10rpx;
  1017. transform: translateY(-50%);
  1018. }
  1019. .btn {
  1020. width: 60rpx;
  1021. height: 32rpx;
  1022. display: inline-block;
  1023. font-size: 28rpx;
  1024. border: 1px solid #fff;
  1025. text-align: center;
  1026. line-height: 30rpx;
  1027. }
  1028. }
  1029. input {
  1030. display: block;
  1031. margin: 8rpx auto;
  1032. width: 720rpx;
  1033. height: 72rpx;
  1034. border: 1rpx solid rgb(153, 153, 153);
  1035. padding-left: 8rpx;
  1036. }
  1037. /deep/.uni-table {
  1038. margin-top: 10rpx;
  1039. // min-width: 100% !important;
  1040. // max-width: 100%;
  1041. }
  1042. .uni-table-th-row {
  1043. padding: 24rpx 0 !important;
  1044. }
  1045. .uni-table-td,
  1046. .uni-table-th {
  1047. font-size: 28rpx;
  1048. }
  1049. .uni-table-th {
  1050. background-color: rgba(242, 242, 242, 1);
  1051. padding: 24rpx 0 !important;
  1052. }
  1053. .table-wrapper {
  1054. height: 75vh;
  1055. overflow: auto;
  1056. padding: 20rpx;
  1057. }
  1058. }
  1059. .sparepart-footer {
  1060. width: 100%;
  1061. height: 80px;
  1062. display: flex;
  1063. align-items: center;
  1064. justify-content: space-around;
  1065. position: fixed;
  1066. bottom: 0;
  1067. background: #fff;
  1068. button {
  1069. width: 300rpx;
  1070. height: 80rpx;
  1071. line-height: 80rpx;
  1072. &.primary {
  1073. background-color: $j-primary-border-green;
  1074. color: #fff;
  1075. }
  1076. }
  1077. }
  1078. .listContent {
  1079. flex: 1;
  1080. overflow: auto;
  1081. padding-bottom: 125rpx;
  1082. .self-table-tr {
  1083. border-bottom: 1rpx solid #ccc;
  1084. }
  1085. }
  1086. .self-table-header {
  1087. padding: 20rpx;
  1088. border-bottom: 1rpx solid #ccc;
  1089. }
  1090. .self-table-tr,
  1091. .self-table-header {
  1092. font-size: 28rpx;
  1093. display: flex;
  1094. justify-content: space-between;
  1095. flex-wrap: wrap;
  1096. .table-date,
  1097. .table-batch,
  1098. .table-code {
  1099. box-sizing: border-box;
  1100. width: 27%;
  1101. padding: 0 5rpx;
  1102. word-break: break-all;
  1103. }
  1104. .table-code {
  1105. width: 50%;
  1106. }
  1107. .table-date {
  1108. width: 37%;
  1109. }
  1110. .other-info {
  1111. color: #aaa;
  1112. width: 100%;
  1113. display: flex;
  1114. justify-content: space-between;
  1115. font-size: 28rpx;
  1116. flex-wrap: wrap;
  1117. > view {
  1118. margin-bottom: 10rpx;
  1119. }
  1120. }
  1121. .checked {
  1122. width: 100%;
  1123. display: flex;
  1124. justify-content: flex-end;
  1125. }
  1126. }
  1127. </style>