sparepart.vue 15 KB

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