index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <view class="order-container">
  3. <scroll-view scroll-y class="order-scroll" :show-scrollbar="false" :enhanced="true">
  4. <view class="form-content">
  5. <!-- 模块 1:型材 -->
  6. <view class="section-card">
  7. <view class="section-header">
  8. <view class="blue-bar"></view>
  9. <text class="section-title">型材</text>
  10. </view>
  11. <view class="form-item">
  12. <text class="label required">型号</text>
  13. <view class="picker-box" @click="openTypePicker">
  14. <view class="picker-inner">
  15. <view class="picker-val" :class="{ placeholder: !formData.type }">
  16. {{ formData.type || '请选择型号' }}
  17. </view>
  18. <view class="line-arrow-down"></view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="row-flex">
  23. <view class="half-item">
  24. <text class="label">名称</text>
  25. <input class="input-box readonly small-font" v-model="formData.name" disabled
  26. placeholder="型号名称" />
  27. </view>
  28. <view class="half-item">
  29. <text class="label">材质</text>
  30. <input class="input-box readonly small-font" v-model="formData.material" disabled
  31. placeholder="材质" />
  32. </view>
  33. </view>
  34. </view>
  35. <!-- 模块 2:表面处理 -->
  36. <view class="section-card">
  37. <view class="section-header">
  38. <view class="blue-bar"></view>
  39. <text class="section-title">表面处理</text>
  40. </view>
  41. <view class="form-item">
  42. <text class="label required">表面名称</text>
  43. <view class="picker-box" @click="openSurfacePicker">
  44. <view class="picker-inner">
  45. <view class="picker-val" :class="{ placeholder: !formData.surfaceName }">
  46. {{ formData.surfaceName || '请选择表面名称' }}
  47. </view>
  48. <view class="line-arrow-down"></view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 模块 3:包装 -->
  54. <view class="section-card">
  55. <view class="section-header">
  56. <view class="blue-bar"></view>
  57. <text class="section-title">包装</text>
  58. </view>
  59. <view class="form-item">
  60. <text class="label required">包装方式</text>
  61. <view class="picker-box" @click="openPackagePicker">
  62. <view class="picker-inner">
  63. <view class="picker-val" :class="{ placeholder: !formData.packageMethod }">
  64. {{ formData.packageMethod || '请选择包装方式' }}
  65. </view>
  66. <view class="line-arrow-down"></view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 模块 4:壁厚 -->
  72. <view class="section-card">
  73. <view class="section-header">
  74. <view class="blue-bar"></view>
  75. <text class="section-title">壁厚</text>
  76. </view>
  77. <view class="row-flex">
  78. <view class="half-item">
  79. <text class="label required">长度</text>
  80. <view class="input-wrap">
  81. <input class="input-box" type="digit" v-model="formData.length" placeholder="请输入" />
  82. <text class="unit">mm</text>
  83. </view>
  84. </view>
  85. <view class="half-item">
  86. <text class="label required">壁厚</text>
  87. <view class="input-wrap">
  88. <input class="input-box" type="digit" v-model="formData.wallThickness"
  89. placeholder="请输入" />
  90. <text class="unit">mm</text>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <!-- 模块 5:数量 -->
  96. <view class="section-card">
  97. <view class="section-header">
  98. <view class="blue-bar"></view>
  99. <text class="section-title">数量</text>
  100. </view>
  101. <view class="form-item no-margin-bottom">
  102. <text class="label required">支数</text>
  103. <input class="input-box full-width" type="number" v-model="formData.count"
  104. placeholder="请输入支付支数" />
  105. </view>
  106. </view>
  107. <view class="bottom-placeholder"></view>
  108. </view>
  109. </scroll-view>
  110. <!-- 底部固定保存按钮 -->
  111. <view class="fixed-submit-bar">
  112. <button class="submit-btn" @click="saveEdit">保存</button>
  113. </view>
  114. <!-- 型号选择 -->
  115. <view class="custom-picker-mask" v-if="showTypePicker" @click="closeTypePicker" @touchmove.stop.prevent>
  116. <view class="picker-popup" @click.stop>
  117. <view class="popup-header">
  118. <text class="cancel-text" @click="closeTypePicker">取消</text>
  119. <text class="popup-title">选择产品型号</text>
  120. <text class="confirm-text" @click="confirmTypeSelect">确定</text>
  121. </view>
  122. <scroll-view scroll-y class="item-list">
  123. <view class="option-item" v-for="(item, index) in typeList" :key="index"
  124. :class="{ active: tempSelectedIndex === index }" @click="selectTypeItem(index)">
  125. <text>{{ item }}</text>
  126. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempSelectedIndex === index">
  127. </icon>
  128. </view>
  129. </scroll-view>
  130. </view>
  131. </view>
  132. <!-- 表面处理选择 -->
  133. <view class="custom-picker-mask" v-if="showSurfacePicker" @click="closeSurfacePicker" @touchmove.stop.prevent>
  134. <view class="picker-popup" @click.stop>
  135. <view class="popup-header">
  136. <text class="cancel-text" @click="closeSurfacePicker">取消</text>
  137. <text class="popup-title">选择表面处理</text>
  138. <text class="confirm-text" @click="confirmSurfaceSelect">确定</text>
  139. </view>
  140. <scroll-view scroll-y class="item-list">
  141. <view class="option-item" v-for="(item, index) in surfaceList" :key="index"
  142. :class="{ active: tempSurfaceIndex === index }" @click="selectSurfaceItem(index)">
  143. <text>{{ item }}</text>
  144. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempSurfaceIndex === index">
  145. </icon>
  146. </view>
  147. </scroll-view>
  148. </view>
  149. </view>
  150. <!-- 包装方式选择 -->
  151. <view class="custom-picker-mask" v-if="showPackagePicker" @click="closePackagePicker" @touchmove.stop.prevent>
  152. <view class="picker-popup" @click.stop>
  153. <view class="popup-header">
  154. <text class="cancel-text" @click="closePackagePicker">取消</text>
  155. <text class="popup-title">选择包装方式</text>
  156. <text class="confirm-text" @click="confirmPackageSelect">确定</text>
  157. </view>
  158. <scroll-view scroll-y class="item-list">
  159. <view class="option-item" v-for="(item, index) in packageList" :key="index"
  160. :class="{ active: tempPackageIndex === index }" @click="selectPackageItem(index)">
  161. <text>{{ item }}</text>
  162. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempPackageIndex === index">
  163. </icon>
  164. </view>
  165. </scroll-view>
  166. </view>
  167. </view>
  168. </view>
  169. </template>
  170. <script>
  171. import typeList from '@/mock/type-list.json';
  172. import surfaceList from '@/json/surface-list.json';
  173. import packageList from '@/json/package-list.json';
  174. export default {
  175. data() {
  176. return {
  177. itemIndex: -1,
  178. showTypePicker: false, showSurfacePicker: false, showPackagePicker: false,
  179. tempSelectedIndex: -1, tempSurfaceIndex: -1, tempPackageIndex: -1,
  180. typeList,
  181. surfaceList,
  182. packageList,
  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>