deviceBom.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name">设备信息</view>
  5. <view class="btn_box rx-bc" @click="handleScan(workOrderId)" v-if='workOrderId'>
  6. <image class="scan" src="@/static/pda/ScanIt.svg"></image>
  7. 更换设备
  8. </view>
  9. </view>
  10. <view class="material rx-ss" v-for="(item,index) in list" :key='index'>
  11. <view class="left rx-ss" @click="getDelete(index)" v-if='workOrderId'>
  12. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"></uni-icons>
  13. </view>
  14. <view class="content_table">
  15. <view class="item">
  16. <view class="lable rx-cc">工位名称</view>
  17. <view class="content">
  18. {{item.workstationName || (item.extInfo && item.extInfo.workstationName)}}
  19. </view>
  20. </view>
  21. <view class="item">
  22. <view class="lable rx-cc">设备编码</view>
  23. <view class="content">
  24. {{ item.code }}
  25. </view>
  26. </view>
  27. <view class="item">
  28. <view class="lable rx-cc">设备名称</view>
  29. <view class="content">{{ item.name }}</view>
  30. </view>
  31. <view class="item rx-sc">
  32. <view class="rx ww50">
  33. <view class="lable rx-cc">固资编码</view>
  34. <view class="content">{{item.extInfo.fixCode }} </view>
  35. </view>
  36. <view class="rx ww50">
  37. <view class="lable ww80 rx-cc">编号</view>
  38. <view class="content">{{item.extInfo.codeNumber}}</view>
  39. </view>
  40. </view>
  41. <view class="item">
  42. <view class="lable rx-cc">炉次号</view>
  43. <view class="content content_num">
  44. <input class="uni-input" v-model="item.extInfo.heatNumber"></input>
  45. </view>
  46. <view v-if="clientEnvironmentId == 2" class="lable rx-cc"
  47. :style="Object.prototype.hasOwnProperty.call(item.extInfo, 'positionList') && item.extInfo.positionList.length > 0 ? 'color: #E6A23C' : 'color: #157A2C'"
  48. @click="handleStorage(index)">货位</view>
  49. </view>
  50. </view>
  51. </view>
  52. <SearchPopup mode="center" v-if='popupShow'>
  53. <template v-slot:list>
  54. <view class="search_list">
  55. <u-form labelPosition="left" :model="formData" labelWidth="90" labelAlign="left" class="baseForm">
  56. <u-form-item label="层数:" class="required-form" borderBottom prop="levelNum">
  57. <u-input v-model="formData.levelNum" :disabled="!ishuoWei" placeholder="请输入">
  58. </u-input>
  59. </u-form-item>
  60. <u-form-item label="列数:" class="required-form" borderBottom prop="lineNum">
  61. <u-input v-model="formData.lineNum" :disabled="!ishuoWei" placeholder="请输入">
  62. </u-input>
  63. </u-form-item>
  64. <view class="rx-bs" style="margin-top: 6rpx;" v-if="ishuoWei">
  65. <u-button size="small" style="width: 260rpx" type="success" @click="handleHjCode()">
  66. 自动生成
  67. </u-button>
  68. <u-button size="small" style="width: 260rpx" type="success" @click="addHjCode()">
  69. 添加货位
  70. </u-button>
  71. </view>
  72. </u-form>
  73. </view>
  74. <view class="content_table2">
  75. <view class="head row rx-sc">
  76. <view class="item ww30">货位</view>
  77. <view class="item ww40">数量</view>
  78. <view class="item ww30">操作</view>
  79. </view>
  80. <view class="table">
  81. <u-list @scrolltolower="scrolltolower" class="z_list">
  82. <view class="tr row rx-sc" v-for="(it, idx) in list[listIndex].extInfo.positionList"
  83. :key='idx'>
  84. <view class="item ww30 content content_num">
  85. <input class="uni-input" :disabled="!ishuoWei" v-model="it.code"></input>
  86. </view>
  87. <view class="item ww40 content content_num">
  88. <input class="uni-input" :disabled="!ishuoWei" v-model="it.num"></input>
  89. </view>
  90. <view class="ww30 rx-cc" @click="removeGoods(idx)" >
  91. <uni-icons custom-prefix="iconfont" v-if="ishuoWei" type="icon-shanchu" size="20"
  92. color="#fa3534"></uni-icons>
  93. </view>
  94. </view>
  95. </u-list>
  96. </view>
  97. </view>
  98. </template>
  99. <template v-slot:operate>
  100. <view class="operate_box rx-bc">
  101. <u-button size="small" class="u-reset-button" @click="handleClose" v-if="ishuoWei">
  102. 清空/取消
  103. </u-button>
  104. <u-button type="success" size="small" class="u-reset-button" @click="handleOk">
  105. 确定
  106. </u-button>
  107. </view>
  108. </template>
  109. </SearchPopup>
  110. </view>
  111. </template>
  112. <script>
  113. import SearchPopup from '../../components/searchPopup.vue'
  114. export default {
  115. components: {
  116. SearchPopup
  117. },
  118. props: {
  119. workOrderId: {
  120. type: String,
  121. default: ''
  122. },
  123. list: {
  124. type: Array,
  125. default: () => []
  126. },
  127. ishuoWei: {
  128. type: Boolean,
  129. default: true
  130. }
  131. },
  132. data() {
  133. return {
  134. popupShow: false,
  135. formData: {
  136. levelNum: null,
  137. lineNum: null,
  138. type: 3,
  139. code: 'A'
  140. },
  141. listIndex: null,
  142. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").clientEnvironmentId
  143. }
  144. },
  145. methods: {
  146. handleScan(id) {
  147. this.$emit('scanIt', id, )
  148. },
  149. getDelete(idx) {
  150. this.list.splice(idx, 1)
  151. },
  152. handleStorage(idx) {
  153. this.listIndex = idx || 0
  154. this.formData.lineNum = this.list[this.listIndex].extInfo.lineNum || null
  155. this.formData.levelNum = this.list[this.listIndex].extInfo.levelNum || null
  156. this.popupShow = true
  157. },
  158. handleHjCode() {
  159. if (!this.formData.levelNum) {
  160. uni.showToast({
  161. title: `请输入层数`,
  162. icon: 'none'
  163. })
  164. return false
  165. }
  166. if (!this.formData.lineNum) {
  167. uni.showToast({
  168. title: `请输入列数`,
  169. icon: 'none'
  170. })
  171. return false
  172. }
  173. this.handleMine()
  174. },
  175. handleMine() {
  176. const ruleName = this.formData.code;
  177. let preCode = 0;
  178. let codeEng = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  179. let currentLetterIndex = 0;
  180. let positionList = []
  181. if (ruleName.length > 0) {
  182. // 计算初始索引
  183. let multiplier = Math.pow(codeEng.length, ruleName.length - 1);
  184. for (let i = 0; i < ruleName.length; i++) {
  185. currentLetterIndex +=
  186. (codeEng.indexOf(ruleName[i]) + 1) * multiplier;
  187. multiplier /= codeEng.length;
  188. }
  189. }
  190. if (this.formData.type == 3) {
  191. for (let i = 0; i < this.formData.lineNum; i++) {
  192. // 获取当前字母
  193. let index = currentLetterIndex;
  194. let dividend = codeEng.length;
  195. let remainder;
  196. let quotient;
  197. let code = '';
  198. while (index > 0) {
  199. remainder = index % dividend;
  200. quotient = Math.floor(index / dividend);
  201. if (remainder === 0) {
  202. remainder = codeEng.length;
  203. quotient--;
  204. }
  205. code = codeEng[remainder - 1] + code;
  206. index = quotient;
  207. }
  208. for (let j = 0; j < this.formData.levelNum; j++) {
  209. let obj1111 = {
  210. code: code + (j + 1),
  211. };
  212. positionList.push(obj1111)
  213. }
  214. console.log(positionList)
  215. this.$set(this.list[this.listIndex].extInfo, 'positionList', positionList)
  216. this.$set(this.list[this.listIndex].extInfo, 'lineNum', this.formData.lineNum)
  217. this.$set(this.list[this.listIndex].extInfo, 'levelNum', this.formData.levelNum)
  218. this.$forceUpdate()
  219. currentLetterIndex++; // 自增索引
  220. }
  221. } else {
  222. let num = Number(this.form.levelNum) * Number(this.form.lineNum)
  223. for (let i = 0; i < num; i++) {
  224. // 获取当前字母
  225. let index = currentLetterIndex;
  226. let dividend = codeEng.length;
  227. let remainder;
  228. let quotient;
  229. let code = '';
  230. while (index > 0) {
  231. remainder = index % dividend;
  232. quotient = Math.floor(index / dividend);
  233. if (remainder === 0) {
  234. remainder = codeEng.length;
  235. quotient--;
  236. }
  237. code = codeEng[remainder - 1] + code;
  238. index = quotient;
  239. }
  240. let obj1111 = {
  241. code: this.formData.type === 1 ? code : ruleName + (i + 1),
  242. };
  243. positionList.push(obj1111)
  244. currentLetterIndex++; // 自增索引
  245. }
  246. }
  247. },
  248. removeGoods(idx) {
  249. if (this.list[this.listIndex].extInfo.positionList == 1) {
  250. uni.showToast({
  251. title: `至少保留一个货架!`,
  252. icon: 'none'
  253. })
  254. return false
  255. }
  256. this.list[this.listIndex].extInfo && this.list[this.listIndex].extInfo.positionList.splice(idx, 1)
  257. },
  258. handleClose() {
  259. this.list[this.listIndex].extInfo.positionList = []
  260. this.list[this.listIndex].extInfo.lineNum = null
  261. this.list[this.listIndex].extInfo.levelNum = null
  262. this.popupShow = false
  263. this.formData.levelNum = null
  264. this.formData.lineNum = null
  265. this.listIndex = 0
  266. },
  267. handleOk() {
  268. this.listIndex = 0
  269. this.popupShow = false
  270. },
  271. addHjCode() {
  272. this.list[this.listIndex].extInfo.positionList.unshift({
  273. code: ''
  274. })
  275. this.$forceUpdate()
  276. },
  277. scrolltolower() {},
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .title_box {
  283. margin-top: 20rpx;
  284. .name {
  285. font-size: 28rpx;
  286. font-style: normal;
  287. font-weight: 400;
  288. color: $theme-color;
  289. padding-left: 20rpx;
  290. position: relative;
  291. &:before {
  292. position: absolute;
  293. content: '';
  294. left: 0rpx;
  295. top: 0rpx;
  296. bottom: 0rpx;
  297. width: 4rpx;
  298. height: 28rpx;
  299. background: $theme-color;
  300. margin: auto;
  301. }
  302. }
  303. .btn_box {
  304. padding: 0 18rpx;
  305. height: 60rpx;
  306. background: $theme-color;
  307. font-size: 26rpx;
  308. font-style: normal;
  309. font-weight: 400;
  310. font-size: 24rpx;
  311. color: #fff;
  312. border-radius: 4rpx;
  313. .scan {
  314. width: 34rpx;
  315. height: 34rpx;
  316. margin-right: 12rpx;
  317. }
  318. }
  319. }
  320. .material {
  321. margin-top: 10rpx;
  322. .content_table {
  323. width: 680rpx;
  324. border: 2rpx solid $border-color;
  325. margin-bottom: 10rpx;
  326. .item {
  327. display: flex;
  328. border-bottom: 2rpx solid $border-color;
  329. .lable {
  330. width: 132rpx;
  331. text-align: center;
  332. background-color: #F7F9FA;
  333. font-size: 26rpx;
  334. border-right: 2rpx solid $border-color;
  335. flex-shrink: 0;
  336. }
  337. .lable150 {
  338. width: 156rpx !important;
  339. font-size: 24rpx;
  340. }
  341. .ww80 {
  342. width: 80rpx;
  343. }
  344. .content {
  345. width: 518rpx;
  346. min-height: 64rpx;
  347. font-size: 28rpx;
  348. line-height: 28rpx;
  349. font-style: normal;
  350. font-weight: 400;
  351. padding: 18rpx 8rpx;
  352. box-sizing: border-box;
  353. word-wrap: break-word;
  354. flex-grow: 1 !important;
  355. .unit {
  356. padding: 0 4rpx;
  357. font-size: 24rpx;
  358. color: #404446;
  359. }
  360. }
  361. .pd4 {
  362. padding: 4rpx 8rpx;
  363. }
  364. &:last-child {
  365. border-bottom: none;
  366. }
  367. }
  368. .ww50 {
  369. width: 50%;
  370. }
  371. .ww55 {
  372. width: 55%;
  373. }
  374. .ww45 {
  375. width: 45%;
  376. }
  377. }
  378. }
  379. .search_list {
  380. min-height: 100rpx;
  381. width: 96vw;
  382. padding: 0 8rpx;
  383. /deep/ .u-form-item__body {
  384. padding: 6rpx 0rpx !important;
  385. }
  386. }
  387. .content_table2 {
  388. width: 100%;
  389. margin-top: 6rpx;
  390. .row {
  391. width: 100%;
  392. .item {
  393. color: #404446;
  394. font-size: 28rpx;
  395. padding-left: 12rpx;
  396. padding-right: 6rpx;
  397. }
  398. .color157 {
  399. color: $theme-color;
  400. }
  401. .ww40 {
  402. width: 40%;
  403. }
  404. .ww30 {
  405. width: 30%;
  406. }
  407. }
  408. .head {
  409. height: 64rpx;
  410. background: #F7F9FA;
  411. border-top: 2rpx solid #E3E5E5;
  412. border-left: 2rpx solid #E3E5E5;
  413. box-sizing: border-box;
  414. .item {
  415. height: 64rpx;
  416. line-height: 64rpx;
  417. border-right: 2rpx solid #E3E5E5;
  418. box-sizing: border-box;
  419. font-size: 24rpx;
  420. }
  421. }
  422. .tr {
  423. border-top: 2rpx solid #E3E5E5;
  424. border-left: 2rpx solid #E3E5E5;
  425. box-sizing: border-box;
  426. .item {
  427. font-size: 24rpx;
  428. min-height: 64rpx;
  429. display: flex;
  430. align-items: center;
  431. border-right: 2rpx solid #E3E5E5;
  432. box-sizing: border-box;
  433. white-space: normal;
  434. word-break: break-all;
  435. }
  436. &:last-child {
  437. border-bottom: 2rpx solid #E3E5E5;
  438. }
  439. }
  440. }
  441. .z_list {
  442. max-height: 500rpx;
  443. }
  444. .content_num {
  445. display: flex;
  446. align-items: center;
  447. padding: 0 4rpx;
  448. /deep/ .uni-input-input {
  449. border: 2rpx solid #F0F8F2;
  450. background: #F0F8F2;
  451. color: $theme-color;
  452. }
  453. }
  454. </style>