sparepart.vue 13 KB

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