sparepart.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. console.log(obj,'obj ----')
  246. this.type = obj.pageType
  247. this.getDept()
  248. if (this.type == 'add') {
  249. this.addForm.repairCode = obj.code;
  250. this.addForm.repairName = obj.planName;
  251. this.addForm.repairId = obj.id;
  252. this.deviceList = obj.deviceList;
  253. this.addForm.receivingDeptName = obj.createGroupName;
  254. this.addForm.recipientName = obj.executeUserName;
  255. // if (!obj.sparePartsApplyList) {
  256. // this.addForm.deviceName = obj.deviceName;
  257. // this.addForm.fixCode = obj.fixCode;
  258. // this.addForm.deviceCode = obj.deviceCode;
  259. // } else {
  260. // this.sparePartsApplyList = obj.sparePartsApplyList;
  261. // }
  262. } else {
  263. const form = await detailsId(obj.id)
  264. this.tableList = form.detailList
  265. this.deviceList = form.deviceList
  266. this.addForm = form
  267. if (this.addForm.useDeptId) {
  268. this.getUser(this.addForm.useDeptId)
  269. }
  270. }
  271. },
  272. methods: {
  273. handleTabChange(value) {
  274. this.active = value
  275. },
  276. openPicker() {
  277. this.$refs.treePicker._show()
  278. },
  279. del(id, type) {
  280. if (this.type != 'add') {
  281. return
  282. }
  283. if (type == 1) {
  284. this.deviceList = this.deviceList.filter((item) => item.id != id);
  285. return
  286. }
  287. this.tableList = this.tableList.filter((item) => item.id != id);
  288. },
  289. sparePartsApplyChange(value) {
  290. const data = this.sparePartsApplyList.find(item => item.value == value)
  291. this.addForm.deviceName = data.text;
  292. this.addForm.fixCode = data.fixCode;
  293. this.addForm.deviceCode = data.deviceCode;
  294. },
  295. // 出库数量限制
  296. handleInput(row, index) {
  297. if (row.totalCount > row.measureQuantity) {
  298. this.$set(this.tableList[index], 'totalCount', row.measureQuantity)
  299. }
  300. },
  301. addPicking() {
  302. uni.navigateTo({
  303. url: `/pages/maintenanceWorkorder/sparepart/sparepartList?codeS=` + JSON.stringify(this
  304. .tableList.map(item => item.categoryCode))
  305. })
  306. },
  307. goHome() {
  308. uni.navigateBack({
  309. delta: 1
  310. })
  311. },
  312. // 提交新增
  313. submitAdd() {
  314. if (this.deviceList.length == 0) {
  315. uni.showToast({
  316. title: '请选择设备!',
  317. icon: 'none'
  318. })
  319. return
  320. }
  321. if (this.tableList.length == 0) {
  322. uni.showToast({
  323. title: '请选择备品备件!',
  324. icon: 'none'
  325. })
  326. return
  327. }
  328. let boolen = this.tableList.every((item) => item.totalCount > 0);
  329. if (!boolen) {
  330. uni.showToast({
  331. title: '请输入出库数量!',
  332. icon: 'none'
  333. })
  334. return
  335. }
  336. uni.showLoading({
  337. title: '加载中'
  338. })
  339. this.addForm.detailList = this.tableList
  340. this.addForm.deviceList = this.deviceList
  341. applySpareParts(this.addForm)
  342. .then(res => {
  343. uni.showToast({
  344. title: '申请成功',
  345. icon: 'success',
  346. duration: 2000
  347. })
  348. setTimeout(() => {
  349. this.goHome()
  350. }, 2000)
  351. })
  352. .catch(e => {
  353. this.loading = false
  354. })
  355. },
  356. confirm(data, name) {
  357. this.addForm.useDeptName = name
  358. this.addForm.useDeptId = data[0]
  359. this.addForm.userName = ''
  360. this.addForm.userId = ''
  361. this.getUser(data[0])
  362. },
  363. getDept() {
  364. listOrganizations(1).then(data => {
  365. this.listData = data
  366. })
  367. },
  368. getUser(deptCode) {
  369. getUserPage({
  370. pageNum: 1,
  371. size: -1,
  372. groupId: deptCode
  373. }).then(data => {
  374. this.userList = data.list.map(item => {
  375. item.text = item.name
  376. item.value = item.id
  377. return item
  378. })
  379. })
  380. },
  381. handleUserChange(obj) {
  382. this.addForm.userName = obj.text
  383. },
  384. }
  385. }
  386. </script>
  387. <style scoped lang="scss">
  388. /deep/.u-subsection__item__text {
  389. font-size: 28rpx !important;
  390. }
  391. /deep/.u-cell__body {
  392. // {
  393. // font-size: 26rpx !important;
  394. // }
  395. // padding: 12rpx 12rpx;
  396. .u-cell__title-text,
  397. .input-value,
  398. .uni-input-wrapper {
  399. font-size: 26rpx !important;
  400. }
  401. }
  402. //底部按钮
  403. .footer {
  404. display: flex;
  405. flex-direction: row;
  406. justify-content: center;
  407. align-items: center;
  408. bottom: 0;
  409. width: 100%;
  410. height: 100rpx;
  411. text-align: center;
  412. position: fixed;
  413. // text {
  414. // width: 100%;
  415. // background-color: $j-primary-green;
  416. // font-size: 34rpx;
  417. // color: #FFFFFF;
  418. // line-height: 100rpx;
  419. // }
  420. text {
  421. width: 100%;
  422. background-color: $j-primary-green;
  423. font-size: 34rpx;
  424. color: #ffffff;
  425. line-height: 100rpx;
  426. }
  427. }
  428. .main {
  429. padding-bottom: 130rpx;
  430. }
  431. .border {
  432. border: 1px solid #eee;
  433. }
  434. .list_box {
  435. flex: 1;
  436. overflow: hidden;
  437. padding: 6rpx 0;
  438. .u-list {
  439. height: 100% !important;
  440. }
  441. }
  442. .list_box {
  443. margin-top: 8rpx;
  444. padding: 8rpx 24rpx;
  445. background: #fff;
  446. /deep/ .uni-checkbox-input-checked {
  447. background-color: $theme-color !important;
  448. border-color: $theme-color !important;
  449. }
  450. .listBox-con {
  451. // width: 650rpx;
  452. font-weight: 400;
  453. }
  454. .listBox-top {
  455. margin-top: 6rpx;
  456. color: #090a0a;
  457. font-size: 28rpx;
  458. font-style: normal;
  459. font-weight: 800;
  460. }
  461. .listBox-bottom {
  462. color: #090a0a;
  463. font-size: 24rpx;
  464. font-style: normal;
  465. flex-wrap: wrap;
  466. .items {
  467. width: calc(50% - 1px);
  468. border-left: 1rpx solid #e3e5e5;
  469. border-right: 1rpx solid #e3e5e5;
  470. border-bottom: 1rpx solid #e3e5e5;
  471. box-sizing: border-box;
  472. word-break: break-all;
  473. text {
  474. display: inline-block;
  475. background: #f7f9fa;
  476. padding: 8rpx 10rpx;
  477. color: #157a2c;
  478. }
  479. &:nth-child(1),
  480. &:nth-child(2) {
  481. border-top: 1rpx solid #e3e5e5;
  482. margin-top: 8rpx;
  483. }
  484. }
  485. }
  486. }
  487. .kd-equipment {
  488. flex: 1;
  489. display: flex;
  490. flex-direction: column;
  491. overflow: hidden;
  492. .kd-type-box {
  493. text-align: center;
  494. padding: 26rpx 0;
  495. view {
  496. position: relative;
  497. display: inline-block;
  498. width: 120rpx;
  499. padding: 4rpx 0;
  500. color: #747474;
  501. margin: 0 20rpx;
  502. background-color: rgba(215, 215, 215, 0.5);
  503. &.type—active {
  504. background-color: #1e7f35;
  505. color: #fff;
  506. }
  507. .count {
  508. position: absolute;
  509. top: -9px;
  510. right: -9px;
  511. width: 18px;
  512. height: 18px;
  513. border-radius: 50%;
  514. font-size: 12px;
  515. background-color: red;
  516. color: #fff;
  517. }
  518. }
  519. }
  520. .kd-list-container {
  521. flex: 1;
  522. display: flex;
  523. flex-direction: column;
  524. overflow: hidden;
  525. padding: 12rpx 18rpx;
  526. background-color: $page-bg;
  527. .u-list {
  528. flex: 1;
  529. height: 100% !important;
  530. }
  531. }
  532. }
  533. .kd-card {
  534. background-color: #fff;
  535. margin-bottom: 20rpx;
  536. padding: 8rpx 0;
  537. font-size: 28rpx;
  538. word-break: break-all;
  539. .kd-card-wrapper {
  540. padding: 0 30rpx;
  541. border-bottom: 1px solid #dadada;
  542. }
  543. .kd-cell {
  544. line-height: 60rpx;
  545. }
  546. .kd-cell:last-of-type {
  547. border-bottom: none;
  548. }
  549. .status-box {
  550. margin-right: 16rpx;
  551. }
  552. .card-footer {
  553. display: flex;
  554. justify-content: flex-end;
  555. align-items: center;
  556. padding: 8rpx 0 20rpx;
  557. button {
  558. width: 180rpx;
  559. height: 56rpx;
  560. line-height: 56rpx;
  561. font-size: 28rpx;
  562. margin: 0 8rpx;
  563. }
  564. .primary-btn {
  565. background-color: $j-primary-border-green;
  566. }
  567. }
  568. }
  569. .kd-cell {
  570. min-height: 90rpx;
  571. border-bottom: 1px dashed #dadada;
  572. display: flex;
  573. align-items: center;
  574. .kd-label {
  575. display: inline-block;
  576. width: 7em;
  577. font-weight: bold;
  578. }
  579. .kd-content {
  580. flex: 1;
  581. word-break: break-all;
  582. }
  583. }
  584. .kd-baseInfo {
  585. padding: 0 32rpx;
  586. font-size: 28rpx;
  587. }
  588. </style>