sparepart.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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. <!-- <input type="text" placeholder="请输入" v-model="form.equiCode"
  25. placeholder-style="color:#999" style="font-size: 28rpx; text-align: right" /> -->
  26. {{ addForm.deviceCode }}
  27. </view>
  28. </Cell>
  29. <Cell cellType="more" title="设备名称">
  30. <view class="cell-tip-right" slot="more" v-if="sparePartsApplyList.length==0">
  31. {{ addForm.deviceName }}
  32. </view>
  33. <view class="cell-tip-right" slot="more" v-else>
  34. <uni-data-select style="width: 500rpx;" v-model="addForm.deviceId"
  35. :localdata="sparePartsApplyList" @change="sparePartsApplyChange"
  36. :clear="true"></uni-data-select>
  37. </view>
  38. </Cell>
  39. <Cell cellType="more" title="固资编码">
  40. <view class="cell-tip-right" slot="more">
  41. {{ addForm.fixCode }}
  42. </view>
  43. </Cell>
  44. <Cell cellType="more" title="领用部门">
  45. <view class="cell-tip-right" slot="more">
  46. {{ addForm.useDeptName }}
  47. </view>
  48. </Cell>
  49. <Cell cellType="more" title="领用人">
  50. <view class="cell-tip-right" slot="more">
  51. {{ addForm.userName }}
  52. </view>
  53. </Cell>
  54. <Cell cellType="more" title="使用时间">
  55. <view class="cell-tip-right" slot="more">
  56. <uni-datetime-picker v-if="type=='add'" type="date" class="picker" v-model="addForm.usageTime">
  57. </uni-datetime-picker>
  58. <text v-else>{{addForm.usageTime}}</text>
  59. </view>
  60. </Cell>
  61. <Cell cellType="more" title="用途">
  62. <u--textarea :disabled="type=='detail'" v-model="addForm.purpose" class="border" maxlength="500"
  63. placeholder="请输入内容" count></u--textarea>
  64. </Cell>
  65. </view>
  66. <view v-show="active==1">
  67. <u-button v-if="type=='add'" type="success" size="small" class="u-reset-button" @click="addPicking()"
  68. text="添加物品"></u-button>
  69. <view class="list_box">
  70. <u-list >
  71. <view v-for="(item, index) in tableList" :key="index" @change="e => selectVal(e, item, index)">
  72. <view class="listBox-con">
  73. <view class="listBox-top rx-bc">
  74. <view @click="del(item.id)"> <uni-icons v-if="type=='add'" custom-prefix="iconfont"
  75. type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  76. {{ item.categoryName }}
  77. </view>
  78. </view>
  79. <view class="listBox-bottom rx">
  80. <view class="items">
  81. <text>编码</text>
  82. {{ item.categoryCode }}
  83. </view>
  84. <view class="items">
  85. <text>牌号</text>
  86. {{ item.brandNum }}
  87. </view>
  88. <view class="items">
  89. <text>型号</text>
  90. {{ item.categoryModel }}
  91. </view>
  92. <view class="items">
  93. <text>规格</text>
  94. {{ item.specification }}
  95. </view>
  96. <view class="items">
  97. <text>级别</text>
  98. {{ item.level }}
  99. </view>
  100. <view class="items" style="display: flex;">
  101. <text>出库数量</text>
  102. <input v-if="type=='add'" style="width: 80px;" v-model="item.totalCount"
  103. type="number" @blur="handleInput(item,index)" placeholder="请输入出库数量" />
  104. <text v-else>{{item.totalCount}}</text>
  105. </view>
  106. <view class="items">
  107. <text>计量数量</text>
  108. {{ item.measureQuantity }}
  109. </view>
  110. <view class="items">
  111. <text>计量单位</text>
  112. {{ item.measureUnit }}
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. <view v-if="tableList.length == 0" style="margin-top: 20vh">
  118. <u-empty iconSize="150" textSize="32" text="暂无数据"></u-empty>
  119. </view>
  120. </u-list>
  121. </view>
  122. </view>
  123. <view class="footer" v-if="type=='add'">
  124. <text @click="submitAdd">提交</text>
  125. </view>
  126. </view>
  127. </template>
  128. <script>
  129. import KdTabs from '@/components/KdTabs.vue'
  130. import {
  131. applySpareParts,
  132. detailsId
  133. } from '@/api/repair'
  134. import Cell from '@/components/Cell.vue'
  135. import {
  136. postJ,
  137. get
  138. } from '@/utils/api.js'
  139. import dayjs from 'dayjs'
  140. export default {
  141. components: {
  142. Cell,
  143. KdTabs
  144. },
  145. data() {
  146. return {
  147. active: 0,
  148. addForm: {
  149. name: '',
  150. repairId: '', //维修工单id
  151. repairCode: '',
  152. code: '',
  153. repairName: '',
  154. deviceName: '',
  155. fixCode: '',
  156. deviceCode: '',
  157. type: '4', //类型
  158. status: '1', //状态
  159. purpose: '',
  160. userId: '', //使用人id
  161. userName: '',
  162. useDeptId: '', //使用部门
  163. useDeptName: '',
  164. warehouseId: '',
  165. usageTime: '', //使用时间 //详情信息
  166. detailList: [],
  167. deviceId:''
  168. },
  169. tableList: [],
  170. sparePartsApplyList: [],
  171. type: 'add',
  172. showTime: '请选择时间',
  173. }
  174. },
  175. onShow() {
  176. uni.$off('sparePartsApply')
  177. uni.$on('sparePartsApply', (data) => {
  178. this.tableList = data
  179. // console.log(data,'data')
  180. })
  181. },
  182. async onLoad(data) {
  183. const obj = JSON.parse(data.data)
  184. this.type = obj.pageType
  185. if (this.type == 'add') {
  186. this.addForm.repairCode = obj.repairCode;
  187. this.addForm.repairName = obj.repairName;
  188. this.addForm.repairId = obj.repairId;
  189. if (!obj.sparePartsApplyList) {
  190. this.addForm.deviceName = obj.deviceName;
  191. this.addForm.fixCode = obj.fixCode;
  192. this.addForm.deviceCode = obj.deviceCode;
  193. } else {
  194. this.sparePartsApplyList = obj.sparePartsApplyList;
  195. }
  196. } else {
  197. const form = await detailsId(obj.id)
  198. this.tableList = form.detailList
  199. this.addForm = form
  200. }
  201. },
  202. methods: {
  203. del(id) {
  204. this.tableList = this.tableList.filter((item) => item.id != id);
  205. },
  206. sparePartsApplyChange(value) {
  207. const data = this.sparePartsApplyList.find(item => item.value == value)
  208. this.addForm.deviceName = data.text;
  209. this.addForm.fixCode = data.fixCode;
  210. this.addForm.deviceCode = data.deviceCode;
  211. },
  212. // 出库数量限制
  213. handleInput(row, index) {
  214. if (row.totalCount > row.measureQuantity) {
  215. this.$set(this.tableList[index], 'totalCount', row.measureQuantity)
  216. }
  217. },
  218. addPicking() {
  219. uni.navigateTo({
  220. url: `/pages/maintenanceWorkorder/sparepart/sparepartList?codeS=` + JSON.stringify(this
  221. .tableList.map(item => item.categoryCode))
  222. })
  223. },
  224. goHome() {
  225. uni.navigateBack({
  226. delta: 1
  227. })
  228. },
  229. // 提交新增
  230. submitAdd() {
  231. if (!this.addForm.deviceName) {
  232. uni.showToast({
  233. title: '请选择设备!',
  234. icon: 'none'
  235. })
  236. return
  237. }
  238. if (this.tableList.length == 0) {
  239. uni.showToast({
  240. title: '请选择备品备件!',
  241. icon: 'none'
  242. })
  243. return
  244. }
  245. let boolen = this.tableList.every((item) => item.totalCount > 0);
  246. if (!boolen) {
  247. uni.showToast({
  248. title: '请输入出库数量!',
  249. icon: 'none'
  250. })
  251. return
  252. }
  253. uni.showLoading({
  254. title: '加载中'
  255. })
  256. this.addForm.detailList = this.tableList
  257. applySpareParts(this.addForm)
  258. .then(res => {
  259. uni.showToast({
  260. title: '申请成功',
  261. icon: 'success',
  262. duration: 2000
  263. })
  264. setTimeout(() => {
  265. this.goHome()
  266. }, 2000)
  267. })
  268. .catch(e => {
  269. this.loading = false
  270. })
  271. },
  272. }
  273. }
  274. </script>
  275. <style scoped lang="scss">
  276. //底部按钮
  277. .footer {
  278. display: flex;
  279. flex-direction: row;
  280. justify-content: center;
  281. align-items: center;
  282. bottom: 0;
  283. width: 100%;
  284. height: 100rpx;
  285. text-align: center;
  286. position: fixed;
  287. // text {
  288. // width: 100%;
  289. // background-color: $j-primary-green;
  290. // font-size: 34rpx;
  291. // color: #FFFFFF;
  292. // line-height: 100rpx;
  293. // }
  294. text {
  295. width: 100%;
  296. background-color: $j-primary-green;
  297. font-size: 34rpx;
  298. color: #ffffff;
  299. line-height: 100rpx;
  300. }
  301. }
  302. .main {
  303. padding-bottom: 130rpx;
  304. }
  305. .border {
  306. border: 1px solid #eee;
  307. }
  308. .list_box {
  309. flex: 1;
  310. overflow: hidden;
  311. padding: 6rpx 0;
  312. .u-list {
  313. height: 100% !important;
  314. }
  315. }
  316. .list_box {
  317. margin-top: 8rpx;
  318. padding: 8rpx 24rpx;
  319. background: #fff;
  320. /deep/ .uni-checkbox-input-checked {
  321. background-color: $theme-color !important;
  322. border-color: $theme-color !important;
  323. }
  324. .listBox-con {
  325. // width: 650rpx;
  326. font-weight: 400;
  327. }
  328. .listBox-top {
  329. margin-top: 6rpx;
  330. color: #090a0a;
  331. font-size: 28rpx;
  332. font-style: normal;
  333. font-weight: 800;
  334. }
  335. .listBox-bottom {
  336. color: #090a0a;
  337. font-size: 24rpx;
  338. font-style: normal;
  339. flex-wrap: wrap;
  340. .items {
  341. width: calc(50% - 1px);
  342. border-left: 1rpx solid #e3e5e5;
  343. border-right: 1rpx solid #e3e5e5;
  344. border-bottom: 1rpx solid #e3e5e5;
  345. box-sizing: border-box;
  346. word-break: break-all;
  347. text {
  348. display: inline-block;
  349. background: #f7f9fa;
  350. padding: 8rpx 10rpx;
  351. color: #157a2c;
  352. }
  353. &:nth-child(1),
  354. &:nth-child(2) {
  355. border-top: 1rpx solid #e3e5e5;
  356. margin-top: 8rpx;
  357. }
  358. }
  359. }
  360. }
  361. </style>