deviceBom.vue 9.6 KB

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