deviceBom.vue 11 KB

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