index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="order-container">
  3. <erp-nav-bar title="编辑型号" />
  4. <scroll-view scroll-y class="order-scroll" :show-scrollbar="false" :enhanced="true">
  5. <view class="form-content">
  6. <!-- 模块 1:型材 -->
  7. <view class="section-card">
  8. <view class="section-header">
  9. <view class="blue-bar"></view>
  10. <text class="section-title">型材</text>
  11. </view>
  12. <view class="form-item">
  13. <text class="label required">型号</text>
  14. <view class="picker-box" @click="openTypePicker">
  15. <view class="picker-inner">
  16. <view class="picker-val" :class="{ placeholder: !formData.type }">
  17. {{ formData.type || '请选择型号' }}
  18. </view>
  19. <view class="line-arrow-down"></view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="row-flex">
  24. <view class="half-item">
  25. <text class="label">名称</text>
  26. <input class="input-box readonly small-font" v-model="formData.name" disabled
  27. placeholder="型号名称" />
  28. </view>
  29. <view class="half-item">
  30. <text class="label">材质</text>
  31. <input class="input-box readonly small-font" v-model="formData.material" disabled
  32. placeholder="材质" />
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 模块 2:表面处理 -->
  37. <view class="section-card">
  38. <view class="section-header">
  39. <view class="blue-bar"></view>
  40. <text class="section-title">表面处理</text>
  41. </view>
  42. <view class="form-item">
  43. <text class="label required">表面名称</text>
  44. <view class="picker-box" @click="openSurfacePicker">
  45. <view class="picker-inner">
  46. <view class="picker-val" :class="{ placeholder: !formData.surfaceName }">
  47. {{ formData.surfaceName || '请选择表面名称' }}
  48. </view>
  49. <view class="line-arrow-down"></view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 模块 3:包装 -->
  55. <view class="section-card">
  56. <view class="section-header">
  57. <view class="blue-bar"></view>
  58. <text class="section-title">包装</text>
  59. </view>
  60. <view class="form-item">
  61. <text class="label required">包装方式</text>
  62. <view class="picker-box" @click="openPackagePicker">
  63. <view class="picker-inner">
  64. <view class="picker-val" :class="{ placeholder: !formData.packageMethod }">
  65. {{ formData.packageMethod || '请选择包装方式' }}
  66. </view>
  67. <view class="line-arrow-down"></view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 模块 4:壁厚 -->
  73. <view class="section-card">
  74. <view class="section-header">
  75. <view class="blue-bar"></view>
  76. <text class="section-title">壁厚</text>
  77. </view>
  78. <view class="row-flex">
  79. <view class="half-item">
  80. <text class="label required">长度</text>
  81. <view class="input-wrap">
  82. <input class="input-box" type="digit" v-model="formData.length" placeholder="请输入" />
  83. <text class="unit">mm</text>
  84. </view>
  85. </view>
  86. <view class="half-item">
  87. <text class="label required">壁厚</text>
  88. <view class="input-wrap">
  89. <input class="input-box" type="digit" v-model="formData.wallThickness"
  90. placeholder="请输入" />
  91. <text class="unit">mm</text>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <!-- 模块 5:数量 -->
  97. <view class="section-card">
  98. <view class="section-header">
  99. <view class="blue-bar"></view>
  100. <text class="section-title">数量</text>
  101. </view>
  102. <view class="form-item no-margin-bottom">
  103. <text class="label required">支数</text>
  104. <input class="input-box full-width" type="number" v-model="formData.count"
  105. placeholder="请输入支付支数" />
  106. </view>
  107. </view>
  108. <view class="bottom-placeholder"></view>
  109. </view>
  110. </scroll-view>
  111. <!-- 底部固定保存按钮 -->
  112. <view class="fixed-submit-bar">
  113. <button class="submit-btn" @click="saveEdit">保存</button>
  114. </view>
  115. <!-- 型号选择 -->
  116. <view class="custom-picker-mask" v-if="showTypePicker" @click="closeTypePicker" @touchmove.stop.prevent>
  117. <view class="picker-popup" @click.stop>
  118. <view class="popup-header">
  119. <text class="cancel-text" @click="closeTypePicker">取消</text>
  120. <text class="popup-title">选择产品型号</text>
  121. <text class="confirm-text" @click="confirmTypeSelect">确定</text>
  122. </view>
  123. <scroll-view scroll-y class="item-list">
  124. <view class="option-item" v-for="(item, index) in typeList" :key="index"
  125. :class="{ active: tempSelectedIndex === index }" @click="selectTypeItem(index)">
  126. <text>{{ item }}</text>
  127. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempSelectedIndex === index">
  128. </icon>
  129. </view>
  130. </scroll-view>
  131. </view>
  132. </view>
  133. <!-- 表面处理选择 -->
  134. <view class="custom-picker-mask" v-if="showSurfacePicker" @click="closeSurfacePicker" @touchmove.stop.prevent>
  135. <view class="picker-popup" @click.stop>
  136. <view class="popup-header">
  137. <text class="cancel-text" @click="closeSurfacePicker">取消</text>
  138. <text class="popup-title">选择表面处理</text>
  139. <text class="confirm-text" @click="confirmSurfaceSelect">确定</text>
  140. </view>
  141. <scroll-view scroll-y class="item-list">
  142. <view class="option-item" v-for="(item, index) in surfaceList" :key="index"
  143. :class="{ active: tempSurfaceIndex === index }" @click="selectSurfaceItem(index)">
  144. <text>{{ item }}</text>
  145. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempSurfaceIndex === index">
  146. </icon>
  147. </view>
  148. </scroll-view>
  149. </view>
  150. </view>
  151. <!-- 包装方式选择 -->
  152. <view class="custom-picker-mask" v-if="showPackagePicker" @click="closePackagePicker" @touchmove.stop.prevent>
  153. <view class="picker-popup" @click.stop>
  154. <view class="popup-header">
  155. <text class="cancel-text" @click="closePackagePicker">取消</text>
  156. <text class="popup-title">选择包装方式</text>
  157. <text class="confirm-text" @click="confirmPackageSelect">确定</text>
  158. </view>
  159. <scroll-view scroll-y class="item-list">
  160. <view class="option-item" v-for="(item, index) in packageList" :key="index"
  161. :class="{ active: tempPackageIndex === index }" @click="selectPackageItem(index)">
  162. <text>{{ item }}</text>
  163. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempPackageIndex === index">
  164. </icon>
  165. </view>
  166. </scroll-view>
  167. </view>
  168. </view>
  169. </view>
  170. </template>
  171. <script>
  172. import ErpNavBar from '@/components/erp-nav-bar.vue';
  173. export default {
  174. components: { ErpNavBar },
  175. data() {
  176. return {
  177. itemIndex: -1,
  178. showTypePicker: false, showSurfacePicker: false, showPackagePicker: false,
  179. tempSelectedIndex: -1, tempSurfaceIndex: -1, tempPackageIndex: -1,
  180. typeList: ['TY0018', 'TY0019', 'TY0020', 'TY0021', 'TY0022', 'TY0023', 'TY0024', 'TY0025', 'TY0026', 'TY0027', 'TY0028'],
  181. surfaceList: ['PL坯料', '阳极氧化', '电泳涂漆', '粉末喷涂', '氟碳喷涂', '木纹转印'],
  182. packageList: ['不贴膜+3点捆扎', '贴膜+纸箱', '气泡膜包装', '简易编织袋', '木托架包装'],
  183. formData: {
  184. type: '', name: '', material: '',
  185. surfaceName: '', packageMethod: '', length: '',
  186. wallThickness: '', count: ''
  187. }
  188. }
  189. },
  190. onLoad(options) {
  191. if (options.data) {
  192. try {
  193. const item = JSON.parse(decodeURIComponent(options.data));
  194. this.formData = item;
  195. this.itemIndex = parseInt(options.index || -1);
  196. } catch (e) {
  197. console.error('Data parse error', e);
  198. }
  199. }
  200. },
  201. methods: {
  202. openTypePicker() { if (this.formData.type) this.tempSelectedIndex = this.typeList.indexOf(this.formData.type); this.showTypePicker = true; },
  203. closeTypePicker() { this.showTypePicker = false; },
  204. selectTypeItem(index) { this.tempSelectedIndex = index; },
  205. confirmTypeSelect() { if (this.tempSelectedIndex === -1) return; const val = this.typeList[this.tempSelectedIndex]; this.formData.type = val; this.formData.name = '工业铝材'; this.formData.material = (this.tempSelectedIndex % 2 === 0) ? '6063-T5' : '6061-T6'; this.closeTypePicker(); },
  206. openSurfacePicker() { if (this.formData.surfaceName) this.tempSurfaceIndex = this.surfaceList.indexOf(this.formData.surfaceName); this.showSurfacePicker = true; },
  207. closeSurfacePicker() { this.showSurfacePicker = false; },
  208. selectSurfaceItem(index) { this.tempSurfaceIndex = index; },
  209. confirmSurfaceSelect() { if (this.tempSurfaceIndex === -1) return; this.formData.surfaceName = this.surfaceList[this.tempSurfaceIndex]; this.closeSurfacePicker(); },
  210. openPackagePicker() { if (this.formData.packageMethod) this.tempPackageIndex = this.packageList.indexOf(this.formData.packageMethod); this.showPackagePicker = true; },
  211. closePackagePicker() { this.showPackagePicker = false; },
  212. selectPackageItem(index) { this.tempPackageIndex = index; },
  213. confirmPackageSelect() { if (this.tempPackageIndex === -1) return; this.formData.packageMethod = this.packageList[this.tempPackageIndex]; this.closePackagePicker(); },
  214. saveEdit() {
  215. const fields = [
  216. { key: 'type', label: '型号' },
  217. { key: 'surfaceName', label: '表面名称' },
  218. { key: 'packageMethod', label: '包装方式' },
  219. { key: 'length', label: '长度' },
  220. { key: 'wallThickness', label: '壁厚' },
  221. { key: 'count', label: '支数' }
  222. ];
  223. for (let item of fields) {
  224. if (!this.formData[item.key]) {
  225. uni.showToast({ title: `请完善项目:${item.label}`, icon: 'none' });
  226. return;
  227. }
  228. }
  229. uni.$emit('update_order_item', {
  230. index: this.itemIndex,
  231. data: JSON.parse(JSON.stringify(this.formData))
  232. });
  233. uni.navigateBack();
  234. }
  235. }
  236. }
  237. </script>
  238. <style scoped>
  239. /deep/ ::-webkit-scrollbar {
  240. display: none !important;
  241. width: 0 !important;
  242. height: 0 !important;
  243. }
  244. .order-container {
  245. width: 100%;
  246. height: 100vh;
  247. background: #f7f8fa;
  248. display: flex;
  249. flex-direction: column;
  250. overflow: hidden;
  251. }
  252. .order-scroll {
  253. flex: 1;
  254. height: 0;
  255. }
  256. .form-content {
  257. padding: 30rpx;
  258. padding-bottom: calc(180rpx + env(safe-area-inset-bottom));
  259. }
  260. .section-card {
  261. background: #fff;
  262. border-radius: 24rpx;
  263. padding: 30rpx;
  264. margin-bottom: 30rpx;
  265. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  266. }
  267. .section-header {
  268. display: flex;
  269. align-items: center;
  270. margin-bottom: 40rpx;
  271. }
  272. .blue-bar {
  273. width: 8rpx;
  274. height: 32rpx;
  275. background: #C1001C;
  276. border-radius: 4rpx;
  277. margin-right: 16rpx;
  278. }
  279. .section-title {
  280. font-size: 32rpx;
  281. font-weight: bold;
  282. color: #333;
  283. }
  284. .form-item {
  285. margin-bottom: 40rpx;
  286. }
  287. .no-margin-bottom {
  288. margin-bottom: 0;
  289. }
  290. .row-flex {
  291. display: flex;
  292. justify-content: space-between;
  293. }
  294. .half-item {
  295. width: 48%;
  296. }
  297. .label {
  298. font-size: 28rpx;
  299. color: #333;
  300. margin-bottom: 20rpx;
  301. display: block;
  302. font-weight: 500;
  303. }
  304. .label.required::after {
  305. content: ' *';
  306. color: #ff4d4f;
  307. font-weight: bold;
  308. margin-left: 4rpx;
  309. }
  310. .picker-box {
  311. background: #f9fafc;
  312. border-radius: 12rpx;
  313. height: 100rpx;
  314. border: 1rpx solid #eee;
  315. display: flex;
  316. align-items: center;
  317. }
  318. .picker-inner {
  319. width: 100%;
  320. height: 100%;
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-between;
  324. padding: 0 30rpx;
  325. box-sizing: border-box;
  326. }
  327. .picker-val {
  328. font-size: 30rpx;
  329. color: #333;
  330. }
  331. .picker-val.placeholder {
  332. color: #ccc;
  333. font-size: 28rpx;
  334. }
  335. .line-arrow-down {
  336. width: 14rpx;
  337. height: 14rpx;
  338. border-right: 3rpx solid #bbb;
  339. border-bottom: 3rpx solid #bbb;
  340. transform: rotate(45deg);
  341. margin-top: -8rpx;
  342. margin-right: 4rpx;
  343. }
  344. .input-wrap {
  345. position: relative;
  346. width: 100%;
  347. }
  348. .input-box {
  349. font-size: 30rpx;
  350. color: #333;
  351. width: 100%;
  352. height: 100rpx;
  353. background: #f9fafc;
  354. border-radius: 12rpx;
  355. padding: 0 80rpx 0 30rpx;
  356. box-sizing: border-box;
  357. border: 1rpx solid #eee;
  358. }
  359. .input-box.readonly {
  360. background: #f8f9fa;
  361. color: #666;
  362. border-color: #f0f0f0;
  363. }
  364. .input-box.full-width {
  365. padding: 0 30rpx;
  366. }
  367. .unit {
  368. position: absolute;
  369. right: 24rpx;
  370. top: 50%;
  371. transform: translateY(-50%);
  372. font-size: 26rpx;
  373. color: #999;
  374. font-weight: 500;
  375. }
  376. .small-font {
  377. font-size: 26rpx !important;
  378. }
  379. .fixed-submit-bar {
  380. position: fixed;
  381. bottom: 0;
  382. left: 0;
  383. width: 100%;
  384. background: #fff;
  385. padding: 20rpx 30rpx calc(env(safe-area-inset-bottom) + 20rpx);
  386. box-sizing: border-box;
  387. box-shadow: 0 -10rpx 30rpx rgba(0, 0, 0, 0.05);
  388. z-index: 100;
  389. }
  390. .submit-btn {
  391. background: #C1001C;
  392. color: #fff;
  393. height: 100rpx;
  394. border-radius: 50rpx;
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. font-size: 34rpx;
  399. font-weight: bold;
  400. border: none;
  401. }
  402. .submit-btn:active {
  403. opacity: 0.9;
  404. transform: scale(0.98);
  405. }
  406. .custom-picker-mask {
  407. position: fixed;
  408. top: 0;
  409. left: 0;
  410. right: 0;
  411. bottom: 0;
  412. background: rgba(0, 0, 0, 0.4);
  413. z-index: 1000;
  414. display: flex;
  415. align-items: flex-end;
  416. }
  417. .picker-popup {
  418. width: 100%;
  419. background: #fff;
  420. border-radius: 32rpx 32rpx 0 0;
  421. padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  422. animation: slideUp 0.15s ease-out;
  423. }
  424. @keyframes slideUp {
  425. from {
  426. transform: translateY(100%);
  427. }
  428. to {
  429. transform: translateY(0);
  430. }
  431. }
  432. .popup-header {
  433. display: flex;
  434. justify-content: space-between;
  435. align-items: center;
  436. padding: 30rpx 40rpx;
  437. border-bottom: 1rpx solid #f0f0f0;
  438. }
  439. .popup-title {
  440. font-size: 32rpx;
  441. font-weight: bold;
  442. color: #333;
  443. }
  444. .cancel-text,
  445. .confirm-text {
  446. font-size: 30rpx;
  447. padding: 10rpx;
  448. }
  449. .confirm-text {
  450. color: #C1001C;
  451. font-weight: bold;
  452. }
  453. .item-list {
  454. max-height: 50vh;
  455. padding: 0 40rpx;
  456. }
  457. .option-item {
  458. height: 110rpx;
  459. display: flex;
  460. align-items: center;
  461. justify-content: space-between;
  462. border-bottom: 1rpx solid #f8f8f8;
  463. font-size: 32rpx;
  464. color: #333;
  465. }
  466. .option-item.active {
  467. color: #C1001C;
  468. font-weight: bold;
  469. }
  470. .bottom-placeholder {
  471. height: 60rpx;
  472. }
  473. </style>