deviceBom.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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. currentLetterIndex++; // 自增索引
  219. }
  220. } else {
  221. let num = Number(this.form.levelNum) * Number(this.form.lineNum)
  222. for (let i = 0; i < num; i++) {
  223. // 获取当前字母
  224. let index = currentLetterIndex;
  225. let dividend = codeEng.length;
  226. let remainder;
  227. let quotient;
  228. let code = '';
  229. while (index > 0) {
  230. remainder = index % dividend;
  231. quotient = Math.floor(index / dividend);
  232. if (remainder === 0) {
  233. remainder = codeEng.length;
  234. quotient--;
  235. }
  236. code = codeEng[remainder - 1] + code;
  237. index = quotient;
  238. }
  239. let obj1111 = {
  240. code: this.formData.type === 1 ? code : ruleName + (i + 1),
  241. };
  242. positionList.push(obj1111)
  243. currentLetterIndex++; // 自增索引
  244. }
  245. }
  246. },
  247. removeGoods(idx) {
  248. if (this.list[this.listIndex].extInfo.positionList == 1) {
  249. uni.showToast({
  250. title: `至少保留一个货架!`,
  251. icon: 'none'
  252. })
  253. return false
  254. }
  255. this.list[this.listIndex].extInfo && this.list[this.listIndex].extInfo.positionList.splice(idx, 1)
  256. },
  257. handleClose() {
  258. this.list[this.listIndex].extInfo.positionList = []
  259. this.list[this.listIndex].extInfo.lineNum = null
  260. this.list[this.listIndex].extInfo.levelNum = null
  261. this.popupShow = false
  262. this.formData.levelNum = null
  263. this.formData.lineNum = null
  264. this.listIndex = 0
  265. },
  266. handleOk() {
  267. this.listIndex = 0
  268. this.popupShow = false
  269. },
  270. addHjCode() {
  271. this.list[this.listIndex].extInfo.positionList.unshift({
  272. code: ''
  273. })
  274. this.$forceUpdate()
  275. },
  276. scrolltolower() {},
  277. }
  278. }
  279. </script>
  280. <style lang="scss" scoped>
  281. .title_box {
  282. margin-top: 20rpx;
  283. .name {
  284. font-size: 28rpx;
  285. font-style: normal;
  286. font-weight: 400;
  287. color: $theme-color;
  288. padding-left: 20rpx;
  289. position: relative;
  290. &:before {
  291. position: absolute;
  292. content: '';
  293. left: 0rpx;
  294. top: 0rpx;
  295. bottom: 0rpx;
  296. width: 4rpx;
  297. height: 28rpx;
  298. background: $theme-color;
  299. margin: auto;
  300. }
  301. }
  302. .btn_box {
  303. padding: 0 18rpx;
  304. height: 60rpx;
  305. background: $theme-color;
  306. font-size: 26rpx;
  307. font-style: normal;
  308. font-weight: 400;
  309. font-size: 24rpx;
  310. color: #fff;
  311. border-radius: 4rpx;
  312. .scan {
  313. width: 34rpx;
  314. height: 34rpx;
  315. margin-right: 12rpx;
  316. }
  317. }
  318. }
  319. .material {
  320. margin-top: 10rpx;
  321. .content_table {
  322. width: 680rpx;
  323. border: 2rpx solid $border-color;
  324. margin-bottom: 10rpx;
  325. .item {
  326. display: flex;
  327. border-bottom: 2rpx solid $border-color;
  328. .lable {
  329. width: 132rpx;
  330. text-align: center;
  331. background-color: #F7F9FA;
  332. font-size: 26rpx;
  333. border-right: 2rpx solid $border-color;
  334. flex-shrink: 0;
  335. }
  336. .lable150 {
  337. width: 156rpx !important;
  338. font-size: 24rpx;
  339. }
  340. .ww80 {
  341. width: 80rpx;
  342. }
  343. .content {
  344. width: 518rpx;
  345. min-height: 64rpx;
  346. font-size: 28rpx;
  347. line-height: 28rpx;
  348. font-style: normal;
  349. font-weight: 400;
  350. padding: 18rpx 8rpx;
  351. box-sizing: border-box;
  352. word-wrap: break-word;
  353. flex-grow: 1 !important;
  354. .unit {
  355. padding: 0 4rpx;
  356. font-size: 24rpx;
  357. color: #404446;
  358. }
  359. }
  360. .pd4 {
  361. padding: 4rpx 8rpx;
  362. }
  363. &:last-child {
  364. border-bottom: none;
  365. }
  366. }
  367. .ww50 {
  368. width: 50%;
  369. }
  370. .ww55 {
  371. width: 55%;
  372. }
  373. .ww45 {
  374. width: 45%;
  375. }
  376. }
  377. }
  378. .search_list {
  379. min-height: 100rpx;
  380. width: 96vw;
  381. padding: 0 8rpx;
  382. /deep/ .u-form-item__body {
  383. padding: 6rpx 0rpx !important;
  384. }
  385. }
  386. .content_table2 {
  387. width: 100%;
  388. margin-top: 6rpx;
  389. .row {
  390. width: 100%;
  391. .item {
  392. color: #404446;
  393. font-size: 28rpx;
  394. padding-left: 12rpx;
  395. padding-right: 6rpx;
  396. }
  397. .color157 {
  398. color: $theme-color;
  399. }
  400. .ww40 {
  401. width: 40%;
  402. }
  403. .ww30 {
  404. width: 30%;
  405. }
  406. }
  407. .head {
  408. height: 64rpx;
  409. background: #F7F9FA;
  410. border-top: 2rpx solid #E3E5E5;
  411. border-left: 2rpx solid #E3E5E5;
  412. box-sizing: border-box;
  413. .item {
  414. height: 64rpx;
  415. line-height: 64rpx;
  416. border-right: 2rpx solid #E3E5E5;
  417. box-sizing: border-box;
  418. font-size: 24rpx;
  419. }
  420. }
  421. .tr {
  422. border-top: 2rpx solid #E3E5E5;
  423. border-left: 2rpx solid #E3E5E5;
  424. box-sizing: border-box;
  425. .item {
  426. font-size: 24rpx;
  427. min-height: 64rpx;
  428. display: flex;
  429. align-items: center;
  430. border-right: 2rpx solid #E3E5E5;
  431. box-sizing: border-box;
  432. white-space: normal;
  433. word-break: break-all;
  434. }
  435. &:last-child {
  436. border-bottom: 2rpx solid #E3E5E5;
  437. }
  438. }
  439. }
  440. .z_list {
  441. max-height: 500rpx;
  442. }
  443. .content_num {
  444. display: flex;
  445. align-items: center;
  446. padding: 0 4rpx;
  447. /deep/ .uni-input-input {
  448. border: 2rpx solid #F0F8F2;
  449. background: #F0F8F2;
  450. color: $theme-color;
  451. }
  452. }
  453. </style>