sparepart.vue 27 KB

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