index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <view class="order-container">
  3. <scroll-view :scroll-y="!showTypePicker && !showSurfacePicker && !showPackagePicker" class="order-scroll"
  4. :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. <view class="fixed-submit-bar">
  112. <button class="submit-btn" @click="confirmAddModel">确认并添加</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. showTypePicker: false, showSurfacePicker: false, showPackagePicker: false,
  178. tempSelectedIndex: -1, tempSurfaceIndex: -1, tempPackageIndex: -1,
  179. typeList,
  180. surfaceList,
  181. packageList,
  182. formData: {
  183. type: '', name: '', material: '',
  184. surfaceName: '', packageMethod: '', length: '',
  185. wallThickness: '', count: ''
  186. }
  187. }
  188. },
  189. methods: {
  190. openTypePicker() { if (this.formData.type) this.tempSelectedIndex = this.typeList.indexOf(this.formData.type); this.showTypePicker = true; },
  191. closeTypePicker() { this.showTypePicker = false; },
  192. selectTypeItem(index) { this.tempSelectedIndex = index; },
  193. 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(); },
  194. openSurfacePicker() { if (this.formData.surfaceName) this.tempSurfaceIndex = this.surfaceList.indexOf(this.formData.surfaceName); this.showSurfacePicker = true; },
  195. closeSurfacePicker() { this.showSurfacePicker = false; },
  196. selectSurfaceItem(index) { this.tempSurfaceIndex = index; },
  197. confirmSurfaceSelect() { if (this.tempSurfaceIndex === -1) return; this.formData.surfaceName = this.surfaceList[this.tempSurfaceIndex]; this.closeSurfacePicker(); },
  198. openPackagePicker() { if (this.formData.packageMethod) this.tempPackageIndex = this.packageList.indexOf(this.formData.packageMethod); this.showPackagePicker = true; },
  199. closePackagePicker() { this.showPackagePicker = false; },
  200. selectPackageItem(index) { this.tempPackageIndex = index; },
  201. confirmPackageSelect() { if (this.tempPackageIndex === -1) return; this.formData.packageMethod = this.packageList[this.tempPackageIndex]; this.closePackagePicker(); },
  202. confirmAddModel() {
  203. const fields = [
  204. { key: 'type', label: '型号' },
  205. { key: 'surfaceName', label: '表面名称' },
  206. { key: 'packageMethod', label: '包装方式' },
  207. { key: 'length', label: '长度' },
  208. { key: 'wallThickness', label: '壁厚' },
  209. { key: 'count', label: '支数' }
  210. ];
  211. for (let item of fields) {
  212. if (!this.formData[item.key]) {
  213. uni.showToast({ title: `请完善项目:${item.label}`, icon: 'none' });
  214. return;
  215. }
  216. }
  217. uni.$emit('add_order_item', JSON.parse(JSON.stringify(this.formData)));
  218. uni.navigateBack();
  219. }
  220. }
  221. }
  222. </script>
  223. <style scoped>
  224. /deep/ ::-webkit-scrollbar {
  225. display: none !important;
  226. width: 0 !important;
  227. height: 0 !important;
  228. }
  229. .order-container {
  230. width: 100%;
  231. height: 100vh;
  232. background: #f7f8fa;
  233. display: flex;
  234. flex-direction: column;
  235. overflow: hidden;
  236. }
  237. .order-scroll {
  238. flex: 1;
  239. height: 0;
  240. }
  241. .form-content {
  242. padding: 30rpx;
  243. padding-bottom: calc(180rpx + env(safe-area-inset-bottom));
  244. }
  245. .section-card {
  246. background: #fff;
  247. border-radius: 24rpx;
  248. padding: 30rpx;
  249. margin-bottom: 30rpx;
  250. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  251. }
  252. .section-header {
  253. display: flex;
  254. align-items: center;
  255. margin-bottom: 40rpx;
  256. }
  257. .blue-bar {
  258. width: 8rpx;
  259. height: 32rpx;
  260. background: #C1001C;
  261. border-radius: 4rpx;
  262. margin-right: 16rpx;
  263. }
  264. .section-title {
  265. font-size: 32rpx;
  266. font-weight: bold;
  267. color: #333;
  268. }
  269. .form-item {
  270. margin-bottom: 40rpx;
  271. }
  272. .no-margin-bottom {
  273. margin-bottom: 0;
  274. }
  275. .row-flex {
  276. display: flex;
  277. justify-content: space-between;
  278. }
  279. .half-item {
  280. width: 48%;
  281. }
  282. .label {
  283. font-size: 28rpx;
  284. color: #333;
  285. margin-bottom: 20rpx;
  286. display: block;
  287. font-weight: 500;
  288. }
  289. .label.required::after {
  290. content: ' *';
  291. color: #ff4d4f;
  292. font-weight: bold;
  293. margin-left: 4rpx;
  294. }
  295. .picker-box {
  296. background: #f9fafc;
  297. border-radius: 12rpx;
  298. height: 100rpx;
  299. border: 1rpx solid #eee;
  300. display: flex;
  301. align-items: center;
  302. }
  303. .picker-inner {
  304. width: 100%;
  305. height: 100%;
  306. display: flex;
  307. align-items: center;
  308. justify-content: space-between;
  309. padding: 0 30rpx;
  310. box-sizing: border-box;
  311. }
  312. .picker-val {
  313. font-size: 30rpx;
  314. color: #333;
  315. }
  316. .picker-val.placeholder {
  317. color: #ccc;
  318. font-size: 28rpx;
  319. }
  320. .line-arrow-down {
  321. width: 14rpx;
  322. height: 14rpx;
  323. border-right: 3rpx solid #bbb;
  324. border-bottom: 3rpx solid #bbb;
  325. transform: rotate(45deg);
  326. margin-top: -8rpx;
  327. margin-right: 4rpx;
  328. }
  329. .input-wrap {
  330. position: relative;
  331. width: 100%;
  332. }
  333. .input-box {
  334. font-size: 30rpx;
  335. color: #333;
  336. width: 100%;
  337. height: 100rpx;
  338. background: #f9fafc;
  339. border-radius: 12rpx;
  340. padding: 0 80rpx 0 30rpx;
  341. box-sizing: border-box;
  342. border: 1rpx solid #eee;
  343. }
  344. .input-box.readonly {
  345. background: #f8f9fa;
  346. color: #666;
  347. border-color: #f0f0f0;
  348. }
  349. .input-box.full-width {
  350. padding: 0 30rpx;
  351. }
  352. .unit {
  353. position: absolute;
  354. right: 24rpx;
  355. top: 50%;
  356. transform: translateY(-50%);
  357. font-size: 26rpx;
  358. color: #999;
  359. font-weight: 500;
  360. }
  361. .small-font {
  362. font-size: 26rpx !important;
  363. }
  364. .fixed-submit-bar {
  365. position: fixed;
  366. bottom: 0;
  367. left: 0;
  368. width: 100%;
  369. background: #fff;
  370. padding: 20rpx 30rpx calc(env(safe-area-inset-bottom) + 20rpx);
  371. box-sizing: border-box;
  372. box-shadow: 0 -10rpx 30rpx rgba(0, 0, 0, 0.05);
  373. z-index: 100;
  374. }
  375. .submit-btn {
  376. background: #C1001C;
  377. color: #fff;
  378. height: 100rpx;
  379. border-radius: 50rpx;
  380. display: flex;
  381. align-items: center;
  382. justify-content: center;
  383. font-size: 34rpx;
  384. font-weight: bold;
  385. border: none;
  386. }
  387. .submit-btn:active {
  388. opacity: 0.9;
  389. transform: scale(0.98);
  390. }
  391. .custom-picker-mask {
  392. position: fixed;
  393. top: 0;
  394. left: 0;
  395. right: 0;
  396. bottom: 0;
  397. background: rgba(0, 0, 0, 0.4);
  398. z-index: 1000;
  399. display: flex;
  400. align-items: flex-end;
  401. }
  402. .picker-popup {
  403. width: 100%;
  404. background: #fff;
  405. border-radius: 32rpx 32rpx 0 0;
  406. padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  407. animation: slideUp 0.15s ease-out;
  408. }
  409. @keyframes slideUp {
  410. from {
  411. transform: translateY(100%);
  412. }
  413. to {
  414. transform: translateY(0);
  415. }
  416. }
  417. .popup-header {
  418. display: flex;
  419. justify-content: space-between;
  420. align-items: center;
  421. padding: 30rpx 40rpx;
  422. border-bottom: 1rpx solid #f0f0f0;
  423. }
  424. .popup-title {
  425. font-size: 32rpx;
  426. font-weight: bold;
  427. color: #333;
  428. }
  429. .cancel-text,
  430. .confirm-text {
  431. font-size: 30rpx;
  432. padding: 10rpx;
  433. }
  434. .confirm-text {
  435. color: #C1001C;
  436. font-weight: bold;
  437. }
  438. .item-list {
  439. max-height: 50vh;
  440. padding: 0 40rpx;
  441. }
  442. .option-item {
  443. height: 110rpx;
  444. display: flex;
  445. align-items: center;
  446. justify-content: space-between;
  447. border-bottom: 1rpx solid #f8f8f8;
  448. font-size: 32rpx;
  449. color: #333;
  450. }
  451. .option-item.active {
  452. color: #C1001C;
  453. font-weight: bold;
  454. }
  455. .bottom-placeholder {
  456. height: 60rpx;
  457. }
  458. </style>