sparepart.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="main">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" right-icon="scan" title="申请备品备件"
  4. @clickLeft="goHome"></uni-nav-bar>
  5. <!-- <KdTabs v-model="active" :list="['基本信息','设备信息','备品备件信息']" /> -->
  6. <u-subsection :list="tabList" :current="active" @change="handleTabChange" active-color="#157a2c"></u-subsection>
  7. <view v-show="active==0">
  8. <Cell cellType="more" title="编号">
  9. <view class="cell-tip-right" slot="more">
  10. {{ addForm.code }}
  11. </view>
  12. </Cell>
  13. <Cell cellType="more" title="工单编码">
  14. <view class="cell-tip-right" slot="more">
  15. {{ addForm.repairCode }}
  16. </view>
  17. </Cell>
  18. <Cell cellType="more" title="工单名称">
  19. <view class="cell-tip-right" slot="more">
  20. {{ addForm.repairName }}
  21. </view>
  22. </Cell>
  23. <!-- <Cell cellType="more" title="设备编号">
  24. <view class="cell-tip-right" slot="more">
  25. {{ addForm.deviceCode }}
  26. </view>
  27. </Cell>
  28. <Cell cellType="more" title="设备名称">
  29. <view class="cell-tip-right" slot="more" v-if="sparePartsApplyList.length==0">
  30. {{ addForm.deviceName }}
  31. </view>
  32. <view class="cell-tip-right" slot="more" v-else>
  33. <uni-data-select style="width: 500rpx;" v-model="addForm.deviceId"
  34. :localdata="sparePartsApplyList" @change="sparePartsApplyChange"
  35. :clear="true"></uni-data-select>
  36. </view>
  37. </Cell>
  38. <Cell cellType="more" title="固资编码">
  39. <view class="cell-tip-right" slot="more">
  40. {{ addForm.fixCode }}
  41. </view>
  42. </Cell> -->
  43. <Cell cellType="more" title="领用部门">
  44. <view class="cell-tip-right" slot="more">
  45. {{ addForm.receivingDeptName }}
  46. </view>
  47. </Cell>
  48. <Cell cellType="more" title="领用人">
  49. <view class="cell-tip-right" slot="more">
  50. {{ addForm.recipientName }}
  51. </view>
  52. </Cell>
  53. <Cell cellType="more" title="使用部门">
  54. <view class="cell-tip-right" slot="more">
  55. <text class="input_text"
  56. @click="openPicker">{{ addForm.useDeptName ? addForm.useDeptName : '请选择' }}</text>
  57. </view>
  58. </Cell>
  59. <Cell cellType="more" title="使用人">
  60. <view class="cell-tip-right" slot="more">
  61. <zxz-uni-data-select v-if="type=='add'" style="width: 300rpx;" :localdata="userList"
  62. v-model="addForm.userId" @change="handleUserChange"></zxz-uni-data-select>
  63. <text v-else>{{addForm.userName}}</text>
  64. </view>
  65. </Cell>
  66. <Cell cellType="more" title="使用时间">
  67. <view class="cell-tip-right" slot="more">
  68. <uni-datetime-picker v-if="type=='add'" type="date" class="picker" v-model="addForm.usageTime">
  69. </uni-datetime-picker>
  70. <text v-else>{{addForm.usageTime}}</text>
  71. </view>
  72. </Cell>
  73. <Cell cellType="more" title="用途">
  74. <u--textarea :disabled="type=='detail'" v-model="addForm.purpose" class="border" maxlength="500"
  75. placeholder="请输入内容" count></u--textarea>
  76. </Cell>
  77. </view>
  78. <view v-show="active==1" class="kd-equipment">
  79. <!-- <u-button v-if="type=='add'" type="success" size="small" class="u-reset-button" @click="addDevice()"
  80. text="添加物品"></u-button> -->
  81. <view class="kd-list-container">
  82. <u-list>
  83. <u-list-item v-for="(item, index) in deviceList" :key="index">
  84. <view class="kd-card">
  85. <view class="kd-card-wrapper">
  86. <uni-icons @click="del(item.id,1)" v-if="type=='add'" custom-prefix="iconfont"
  87. type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  88. <view class="kd-cell">
  89. <text class="kd-label">设备编码</text>
  90. {{ item.code }}
  91. </view>
  92. <view class="kd-cell">
  93. <text class="kd-label">设备名称</text>
  94. {{ item.name }}
  95. </view>
  96. <view class="kd-cell">
  97. <text class="kd-label">设备型号</text>
  98. {{ item.category&&item.category.modelType||item.model }}
  99. </view>
  100. <!-- <view class="kd-cell">
  101. <text class="kd-label">设备位置</text>
  102. {{ item.deviceLocationName.pathName }}
  103. </view> -->
  104. </view>
  105. </view>
  106. </u-list-item>
  107. </u-list>
  108. </view>
  109. </view>
  110. <view v-show="active==2">
  111. <u-button v-if="type=='add'" type="success" size="small" class="u-reset-button" @click="addPicking()"
  112. text="添加物品"></u-button>
  113. <view class="list_box">
  114. <u-list>
  115. <view v-for="(item, index) in tableList" :key="index" @change="e => selectVal(e, item, index)">
  116. <view class="listBox-con">
  117. <view class="listBox-top rx-bc">
  118. <view @click="del(item.id)"> <uni-icons v-if="type=='add'" custom-prefix="iconfont"
  119. type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  120. {{ item.categoryName }}
  121. </view>
  122. </view>
  123. <view class="listBox-bottom rx">
  124. <view class="items">
  125. <text>编码</text>
  126. {{ item.categoryCode }}
  127. </view>
  128. <view class="items">
  129. <text>牌号</text>
  130. {{ item.brandNum }}
  131. </view>
  132. <view class="items">
  133. <text>型号</text>
  134. {{ item.categoryModel }}
  135. </view>
  136. <view class="items">
  137. <text>规格</text>
  138. {{ item.specification }}
  139. </view>
  140. <view class="items">
  141. <text>级别</text>
  142. {{ item.level }}
  143. </view>
  144. <view class="items" style="display: flex;">
  145. <text>出库数量</text>
  146. <input v-if="type=='add'" style="width: 80px;" v-model="item.totalCount"
  147. type="number" @blur="handleInput(item,index)" placeholder="请输入出库数量" />
  148. <text v-else>{{item.totalCount}}</text>
  149. </view>
  150. <view class="items">
  151. <text>计量数量</text>
  152. {{ item.measureQuantity }}
  153. </view>
  154. <view class="items">
  155. <text>计量单位</text>
  156. {{ item.measureUnit }}
  157. </view>
  158. </view>
  159. </view>
  160. </view>
  161. <view v-if="tableList.length == 0" style="margin-top: 20vh">
  162. <u-empty iconSize="150" textSize="32" text="暂无数据"></u-empty>
  163. </view>
  164. </u-list>
  165. </view>
  166. </view>
  167. <view class="footer" v-if="type=='add'">
  168. <text @click="submitAdd">提交</text>
  169. </view>
  170. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
  171. valueKey="id" textKey="name" childrenKey="children" />
  172. </view>
  173. </template>
  174. <script>
  175. import KdTabs from '@/components/KdTabs.vue'
  176. import {
  177. listOrganizations,
  178. getUserPage
  179. } from '@/api/myTicket/index.js'
  180. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  181. import {
  182. applySpareParts,
  183. detailsId
  184. } from '@/api/repair'
  185. import Cell from '@/components/Cell.vue'
  186. import {
  187. postJ,
  188. get
  189. } from '@/utils/api.js'
  190. import dayjs from 'dayjs'
  191. export default {
  192. components: {
  193. Cell,
  194. KdTabs,
  195. baTreePicker
  196. },
  197. data() {
  198. return {
  199. active: 0,
  200. tabList: ['基本信息', '设备信息', '备品备件信息'],
  201. addForm: {
  202. name: '',
  203. repairId: '', //维修工单id
  204. repairCode: '',
  205. code: '',
  206. repairName: '',
  207. deviceName: '',
  208. fixCode: '',
  209. deviceCode: '',
  210. type: '4', //类型
  211. status: '1', //状态
  212. purpose: '',
  213. userId: '', //使用人id
  214. userName: '',
  215. useDeptId: '', //使用部门
  216. useDeptName: '',
  217. warehouseId: '',
  218. usageTime: '', //使用时间 //详情信息
  219. detailList: [],
  220. deviceId: '',
  221. executorDeptName: ''
  222. },
  223. tableList: [],
  224. deviceList: [],
  225. // sparePartsApplyList: [],
  226. type: 'add',
  227. showTime: '请选择时间',
  228. userList: [],
  229. listData: []
  230. }
  231. },
  232. onShow() {
  233. uni.$off('sparePartsApply')
  234. uni.$on('sparePartsApply', (data) => {
  235. this.tableList = data
  236. // console.log(data,'data')
  237. })
  238. },
  239. async onLoad(data) {
  240. const obj = JSON.parse(data.data)
  241. this.type = obj.pageType
  242. this.getDept()
  243. if (this.type == 'add') {
  244. this.addForm.repairCode = obj.code;
  245. this.addForm.repairName = obj.planName;
  246. this.addForm.repairId = obj.id;
  247. this.deviceList = obj.deviceList;
  248. // if (!obj.sparePartsApplyList) {
  249. // this.addForm.deviceName = obj.deviceName;
  250. // this.addForm.fixCode = obj.fixCode;
  251. // this.addForm.deviceCode = obj.deviceCode;
  252. // } else {
  253. // this.sparePartsApplyList = obj.sparePartsApplyList;
  254. // }
  255. } else {
  256. const form = await detailsId(obj.id)
  257. this.tableList = form.detailList
  258. this.deviceList = form.deviceList
  259. this.addForm = form
  260. if (this.addForm.useDeptId) {
  261. this.getUser(this.addForm.useDeptId)
  262. }
  263. }
  264. },
  265. methods: {
  266. handleTabChange(value) {
  267. this.active = value
  268. },
  269. openPicker() {
  270. this.$refs.treePicker._show()
  271. },
  272. del(id, type) {
  273. if (this.type != 'add') {
  274. return
  275. }
  276. if (type == 1) {
  277. this.deviceList = this.deviceList.filter((item) => item.id != id);
  278. return
  279. }
  280. this.tableList = this.tableList.filter((item) => item.id != id);
  281. },
  282. sparePartsApplyChange(value) {
  283. const data = this.sparePartsApplyList.find(item => item.value == value)
  284. this.addForm.deviceName = data.text;
  285. this.addForm.fixCode = data.fixCode;
  286. this.addForm.deviceCode = data.deviceCode;
  287. },
  288. // 出库数量限制
  289. handleInput(row, index) {
  290. if (row.totalCount > row.measureQuantity) {
  291. this.$set(this.tableList[index], 'totalCount', row.measureQuantity)
  292. }
  293. },
  294. addPicking() {
  295. uni.navigateTo({
  296. url: `/pages/maintenanceWorkorder/sparepart/sparepartList?codeS=` + JSON.stringify(this
  297. .tableList.map(item => item.categoryCode))
  298. })
  299. },
  300. goHome() {
  301. uni.navigateBack({
  302. delta: 1
  303. })
  304. },
  305. // 提交新增
  306. submitAdd() {
  307. if (this.deviceList.length == 0) {
  308. uni.showToast({
  309. title: '请选择设备!',
  310. icon: 'none'
  311. })
  312. return
  313. }
  314. if (this.tableList.length == 0) {
  315. uni.showToast({
  316. title: '请选择备品备件!',
  317. icon: 'none'
  318. })
  319. return
  320. }
  321. let boolen = this.tableList.every((item) => item.totalCount > 0);
  322. if (!boolen) {
  323. uni.showToast({
  324. title: '请输入出库数量!',
  325. icon: 'none'
  326. })
  327. return
  328. }
  329. uni.showLoading({
  330. title: '加载中'
  331. })
  332. this.addForm.detailList = this.tableList
  333. this.addForm.deviceList = this.deviceList
  334. applySpareParts(this.addForm)
  335. .then(res => {
  336. uni.showToast({
  337. title: '申请成功',
  338. icon: 'success',
  339. duration: 2000
  340. })
  341. setTimeout(() => {
  342. this.goHome()
  343. }, 2000)
  344. })
  345. .catch(e => {
  346. this.loading = false
  347. })
  348. },
  349. confirm(data, name) {
  350. this.addForm.useDeptName = name
  351. this.addForm.useDeptId = data[0]
  352. this.addForm.userName = ''
  353. this.addForm.userId = ''
  354. this.getUser(data[0])
  355. },
  356. getDept() {
  357. listOrganizations(1).then(data => {
  358. this.listData = data
  359. })
  360. },
  361. getUser(deptCode) {
  362. getUserPage({
  363. pageNum: 1,
  364. size: -1,
  365. groupId: deptCode
  366. }).then(data => {
  367. this.userList = data.list.map(item => {
  368. item.text = item.name
  369. item.value = item.id
  370. return item
  371. })
  372. })
  373. },
  374. handleUserChange(obj) {
  375. this.addForm.userName = obj.text
  376. },
  377. }
  378. }
  379. </script>
  380. <style scoped lang="scss">
  381. /deep/.u-subsection__item__text {
  382. font-size: 28rpx !important;
  383. }
  384. /deep/.u-cell__body {
  385. // {
  386. // font-size: 26rpx !important;
  387. // }
  388. // padding: 12rpx 12rpx;
  389. .u-cell__title-text,
  390. .input-value,
  391. .uni-input-wrapper {
  392. font-size: 26rpx !important;
  393. }
  394. }
  395. //底部按钮
  396. .footer {
  397. display: flex;
  398. flex-direction: row;
  399. justify-content: center;
  400. align-items: center;
  401. bottom: 0;
  402. width: 100%;
  403. height: 100rpx;
  404. text-align: center;
  405. position: fixed;
  406. // text {
  407. // width: 100%;
  408. // background-color: $j-primary-green;
  409. // font-size: 34rpx;
  410. // color: #FFFFFF;
  411. // line-height: 100rpx;
  412. // }
  413. text {
  414. width: 100%;
  415. background-color: $j-primary-green;
  416. font-size: 34rpx;
  417. color: #ffffff;
  418. line-height: 100rpx;
  419. }
  420. }
  421. .main {
  422. padding-bottom: 130rpx;
  423. }
  424. .border {
  425. border: 1px solid #eee;
  426. }
  427. .list_box {
  428. flex: 1;
  429. overflow: hidden;
  430. padding: 6rpx 0;
  431. .u-list {
  432. height: 100% !important;
  433. }
  434. }
  435. .list_box {
  436. margin-top: 8rpx;
  437. padding: 8rpx 24rpx;
  438. background: #fff;
  439. /deep/ .uni-checkbox-input-checked {
  440. background-color: $theme-color !important;
  441. border-color: $theme-color !important;
  442. }
  443. .listBox-con {
  444. // width: 650rpx;
  445. font-weight: 400;
  446. }
  447. .listBox-top {
  448. margin-top: 6rpx;
  449. color: #090a0a;
  450. font-size: 28rpx;
  451. font-style: normal;
  452. font-weight: 800;
  453. }
  454. .listBox-bottom {
  455. color: #090a0a;
  456. font-size: 24rpx;
  457. font-style: normal;
  458. flex-wrap: wrap;
  459. .items {
  460. width: calc(50% - 1px);
  461. border-left: 1rpx solid #e3e5e5;
  462. border-right: 1rpx solid #e3e5e5;
  463. border-bottom: 1rpx solid #e3e5e5;
  464. box-sizing: border-box;
  465. word-break: break-all;
  466. text {
  467. display: inline-block;
  468. background: #f7f9fa;
  469. padding: 8rpx 10rpx;
  470. color: #157a2c;
  471. }
  472. &:nth-child(1),
  473. &:nth-child(2) {
  474. border-top: 1rpx solid #e3e5e5;
  475. margin-top: 8rpx;
  476. }
  477. }
  478. }
  479. }
  480. .kd-equipment {
  481. flex: 1;
  482. display: flex;
  483. flex-direction: column;
  484. overflow: hidden;
  485. .kd-type-box {
  486. text-align: center;
  487. padding: 26rpx 0;
  488. view {
  489. position: relative;
  490. display: inline-block;
  491. width: 120rpx;
  492. padding: 4rpx 0;
  493. color: #747474;
  494. margin: 0 20rpx;
  495. background-color: rgba(215, 215, 215, 0.5);
  496. &.type—active {
  497. background-color: #1e7f35;
  498. color: #fff;
  499. }
  500. .count {
  501. position: absolute;
  502. top: -9px;
  503. right: -9px;
  504. width: 18px;
  505. height: 18px;
  506. border-radius: 50%;
  507. font-size: 12px;
  508. background-color: red;
  509. color: #fff;
  510. }
  511. }
  512. }
  513. .kd-list-container {
  514. flex: 1;
  515. display: flex;
  516. flex-direction: column;
  517. overflow: hidden;
  518. padding: 12rpx 18rpx;
  519. background-color: $page-bg;
  520. .u-list {
  521. flex: 1;
  522. height: 100% !important;
  523. }
  524. }
  525. }
  526. .kd-card {
  527. background-color: #fff;
  528. margin-bottom: 20rpx;
  529. padding: 8rpx 0;
  530. font-size: 28rpx;
  531. word-break: break-all;
  532. .kd-card-wrapper {
  533. padding: 0 30rpx;
  534. border-bottom: 1px solid #dadada;
  535. }
  536. .kd-cell {
  537. line-height: 60rpx;
  538. }
  539. .kd-cell:last-of-type {
  540. border-bottom: none;
  541. }
  542. .status-box {
  543. margin-right: 16rpx;
  544. }
  545. .card-footer {
  546. display: flex;
  547. justify-content: flex-end;
  548. align-items: center;
  549. padding: 8rpx 0 20rpx;
  550. button {
  551. width: 180rpx;
  552. height: 56rpx;
  553. line-height: 56rpx;
  554. font-size: 28rpx;
  555. margin: 0 8rpx;
  556. }
  557. .primary-btn {
  558. background-color: $j-primary-border-green;
  559. }
  560. }
  561. }
  562. .kd-cell {
  563. min-height: 90rpx;
  564. border-bottom: 1px dashed #dadada;
  565. display: flex;
  566. align-items: center;
  567. .kd-label {
  568. display: inline-block;
  569. width: 7em;
  570. font-weight: bold;
  571. }
  572. .kd-content {
  573. flex: 1;
  574. word-break: break-all;
  575. }
  576. }
  577. .kd-baseInfo {
  578. padding: 0 32rpx;
  579. font-size: 28rpx;
  580. }
  581. </style>