edit_model.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view class="order-container">
  3. <scroll-view
  4. scroll-y
  5. class="order-scroll"
  6. :show-scrollbar="false"
  7. :enhanced="true">
  8. <view class="form-content">
  9. <!-- 模块 1:型材 -->
  10. <view class="section-card">
  11. <view class="section-header">
  12. <view class="blue-bar"></view>
  13. <text class="section-title">型材</text>
  14. </view>
  15. <view class="form-item">
  16. <text class="label required">型号</text>
  17. <view class="picker-box" @click="openTypePicker">
  18. <view class="picker-inner">
  19. <view class="picker-val" :class="{placeholder: !formData.type}">
  20. {{ formData.type || '请选择型号' }}
  21. </view>
  22. <view class="line-arrow-down"></view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="row-flex">
  27. <view class="half-item">
  28. <text class="label">名称</text>
  29. <input class="input-box readonly small-font" v-model="formData.name" disabled placeholder="型号名称" />
  30. </view>
  31. <view class="half-item">
  32. <text class="label">材质</text>
  33. <input class="input-box readonly small-font" v-model="formData.material" disabled placeholder="材质" />
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 模块 2:表面处理 -->
  38. <view class="section-card">
  39. <view class="section-header">
  40. <view class="blue-bar"></view>
  41. <text class="section-title">表面处理</text>
  42. </view>
  43. <view class="form-item">
  44. <text class="label required">表面名称</text>
  45. <view class="picker-box" @click="openSurfacePicker">
  46. <view class="picker-inner">
  47. <view class="picker-val" :class="{placeholder: !formData.surfaceName}">
  48. {{ formData.surfaceName || '请选择表面名称' }}
  49. </view>
  50. <view class="line-arrow-down"></view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 模块 3:包装 -->
  56. <view class="section-card">
  57. <view class="section-header">
  58. <view class="blue-bar"></view>
  59. <text class="section-title">包装</text>
  60. </view>
  61. <view class="form-item">
  62. <text class="label required">包装方式</text>
  63. <view class="picker-box" @click="openPackagePicker">
  64. <view class="picker-inner">
  65. <view class="picker-val" :class="{placeholder: !formData.packageMethod}">
  66. {{ formData.packageMethod || '请选择包装方式' }}
  67. </view>
  68. <view class="line-arrow-down"></view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 模块 4:壁厚 -->
  74. <view class="section-card">
  75. <view class="section-header">
  76. <view class="blue-bar"></view>
  77. <text class="section-title">壁厚</text>
  78. </view>
  79. <view class="row-flex">
  80. <view class="half-item">
  81. <text class="label required">长度</text>
  82. <view class="input-wrap">
  83. <input class="input-box" type="digit" v-model="formData.length" placeholder="请输入" />
  84. <text class="unit">mm</text>
  85. </view>
  86. </view>
  87. <view class="half-item">
  88. <text class="label required">壁厚</text>
  89. <view class="input-wrap">
  90. <input class="input-box" type="digit" v-model="formData.wallThickness" 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" 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"></icon>
  127. </view>
  128. </scroll-view>
  129. </view>
  130. </view>
  131. <!-- 表面处理选择 -->
  132. <view class="custom-picker-mask" v-if="showSurfacePicker" @click="closeSurfacePicker" @touchmove.stop.prevent>
  133. <view class="picker-popup" @click.stop>
  134. <view class="popup-header">
  135. <text class="cancel-text" @click="closeSurfacePicker">取消</text>
  136. <text class="popup-title">选择表面处理</text>
  137. <text class="confirm-text" @click="confirmSurfaceSelect">确定</text>
  138. </view>
  139. <scroll-view scroll-y class="item-list">
  140. <view class="option-item" v-for="(item, index) in surfaceList" :key="index"
  141. :class="{active: tempSurfaceIndex === index}" @click="selectSurfaceItem(index)">
  142. <text>{{item}}</text>
  143. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempSurfaceIndex === index"></icon>
  144. </view>
  145. </scroll-view>
  146. </view>
  147. </view>
  148. <!-- 包装方式选择 -->
  149. <view class="custom-picker-mask" v-if="showPackagePicker" @click="closePackagePicker" @touchmove.stop.prevent>
  150. <view class="picker-popup" @click.stop>
  151. <view class="popup-header">
  152. <text class="cancel-text" @click="closePackagePicker">取消</text>
  153. <text class="popup-title">选择包装方式</text>
  154. <text class="confirm-text" @click="confirmPackageSelect">确定</text>
  155. </view>
  156. <scroll-view scroll-y class="item-list">
  157. <view class="option-item" v-for="(item, index) in packageList" :key="index"
  158. :class="{active: tempPackageIndex === index}" @click="selectPackageItem(index)">
  159. <text>{{item}}</text>
  160. <icon type="success_no_circle" size="16" color="#C1001C" v-if="tempPackageIndex === index"></icon>
  161. </view>
  162. </scroll-view>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. export default {
  169. data() {
  170. return {
  171. itemIndex: -1,
  172. showTypePicker: false, showSurfacePicker: false, showPackagePicker: false,
  173. tempSelectedIndex: -1, tempSurfaceIndex: -1, tempPackageIndex: -1,
  174. typeList: ['TY0018', 'TY0019', 'TY0020', 'TY0021', 'TY0022', 'TY0023', 'TY0024', 'TY0025', 'TY0026', 'TY0027', 'TY0028'],
  175. surfaceList: ['PL坯料', '阳极氧化', '电泳涂漆', '粉末喷涂', '氟碳喷涂', '木纹转印'],
  176. packageList: ['不贴膜+3点捆扎', '贴膜+纸箱', '气泡膜包装', '简易编织袋', '木托架包装'],
  177. formData: {
  178. type: '', name: '', material: '',
  179. surfaceName: '', packageMethod: '', length: '',
  180. wallThickness: '', count: ''
  181. }
  182. }
  183. },
  184. onLoad(options) {
  185. if (options.data) {
  186. try {
  187. const item = JSON.parse(decodeURIComponent(options.data));
  188. this.formData = item;
  189. this.itemIndex = parseInt(options.index || -1);
  190. } catch (e) {
  191. console.error('Data parse error', e);
  192. }
  193. }
  194. },
  195. methods: {
  196. openTypePicker() { if (this.formData.type) this.tempSelectedIndex = this.typeList.indexOf(this.formData.type); this.showTypePicker = true; },
  197. closeTypePicker() { this.showTypePicker = false; },
  198. selectTypeItem(index) { this.tempSelectedIndex = index; },
  199. 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(); },
  200. openSurfacePicker() { if (this.formData.surfaceName) this.tempSurfaceIndex = this.surfaceList.indexOf(this.formData.surfaceName); this.showSurfacePicker = true; },
  201. closeSurfacePicker() { this.showSurfacePicker = false; },
  202. selectSurfaceItem(index) { this.tempSurfaceIndex = index; },
  203. confirmSurfaceSelect() { if (this.tempSurfaceIndex === -1) return; this.formData.surfaceName = this.surfaceList[this.tempSurfaceIndex]; this.closeSurfacePicker(); },
  204. openPackagePicker() { if (this.formData.packageMethod) this.tempPackageIndex = this.packageList.indexOf(this.formData.packageMethod); this.showPackagePicker = true; },
  205. closePackagePicker() { this.showPackagePicker = false; },
  206. selectPackageItem(index) { this.tempPackageIndex = index; },
  207. confirmPackageSelect() { if (this.tempPackageIndex === -1) return; this.formData.packageMethod = this.packageList[this.tempPackageIndex]; this.closePackagePicker(); },
  208. saveEdit() {
  209. const fields = [
  210. { key: 'type', label: '型号' },
  211. { key: 'surfaceName', label: '表面名称' },
  212. { key: 'packageMethod', label: '包装方式' },
  213. { key: 'length', label: '长度' },
  214. { key: 'wallThickness', label: '壁厚' },
  215. { key: 'count', label: '支数' }
  216. ];
  217. for (let item of fields) {
  218. if (!this.formData[item.key]) {
  219. uni.showToast({ title: `请完善项目:${item.label}`, icon: 'none' });
  220. return;
  221. }
  222. }
  223. uni.$emit('update_order_item', {
  224. index: this.itemIndex,
  225. data: JSON.parse(JSON.stringify(this.formData))
  226. });
  227. uni.navigateBack();
  228. }
  229. }
  230. }
  231. </script>
  232. <style scoped>
  233. /deep/ ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }
  234. .order-container { width: 100%; height: 100vh; background: #f7f8fa; display: flex; flex-direction: column; overflow: hidden; }
  235. .order-scroll { flex: 1; height: 0; }
  236. .form-content {
  237. padding: 30rpx;
  238. padding-bottom: calc(180rpx + env(safe-area-inset-bottom));
  239. }
  240. .section-card { background: #fff; border-radius: 24rpx; padding: 30rpx; margin-bottom: 30rpx; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.02); }
  241. .section-header { display: flex; align-items: center; margin-bottom: 40rpx; }
  242. .blue-bar { width: 8rpx; height: 32rpx; background: #C1001C; border-radius: 4rpx; margin-right: 16rpx; }
  243. .section-title { font-size: 32rpx; font-weight: bold; color: #333; }
  244. .form-item { margin-bottom: 40rpx; }
  245. .no-margin-bottom { margin-bottom: 0; }
  246. .row-flex { display: flex; justify-content: space-between; }
  247. .half-item { width: 48%; }
  248. .label { font-size: 28rpx; color: #333; margin-bottom: 20rpx; display: block; font-weight: 500; }
  249. .label.required::after { content: ' *'; color: #ff4d4f; font-weight: bold; margin-left: 4rpx; }
  250. .picker-box { background: #f9fafc; border-radius: 12rpx; height: 100rpx; border: 1rpx solid #eee; display: flex; align-items: center; }
  251. .picker-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: space-between; padding: 0 30rpx; box-sizing: border-box; }
  252. .picker-val { font-size: 30rpx; color: #333; }
  253. .picker-val.placeholder { color: #ccc; font-size: 28rpx; }
  254. .line-arrow-down { width: 14rpx; height: 14rpx; border-right: 3rpx solid #bbb; border-bottom: 3rpx solid #bbb; transform: rotate(45deg); margin-top: -8rpx; margin-right: 4rpx; }
  255. .input-wrap { position: relative; width: 100%; }
  256. .input-box { font-size: 30rpx; color: #333; width: 100%; height: 100rpx; background: #f9fafc; border-radius: 12rpx; padding: 0 80rpx 0 30rpx; box-sizing: border-box; border: 1rpx solid #eee; }
  257. .input-box.readonly { background: #f8f9fa; color: #666; border-color: #f0f0f0; }
  258. .input-box.full-width { padding: 0 30rpx; }
  259. .unit { position: absolute; right: 24rpx; top: 50%; transform: translateY(-50%); font-size: 26rpx; color: #999; font-weight: 500; }
  260. .small-font { font-size: 26rpx !important; }
  261. .fixed-submit-bar {
  262. position: fixed;
  263. bottom: 0;
  264. left: 0;
  265. width: 100%;
  266. background: #fff;
  267. padding: 20rpx 30rpx calc(env(safe-area-inset-bottom) + 20rpx);
  268. box-sizing: border-box;
  269. box-shadow: 0 -10rpx 30rpx rgba(0,0,0,0.05);
  270. z-index: 100;
  271. }
  272. .submit-btn {
  273. background: #C1001C;
  274. color: #fff;
  275. height: 100rpx;
  276. border-radius: 50rpx;
  277. display: flex;
  278. align-items: center;
  279. justify-content: center;
  280. font-size: 34rpx;
  281. font-weight: bold;
  282. border: none;
  283. }
  284. .submit-btn:active { opacity: 0.9; transform: scale(0.98); }
  285. .custom-picker-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 1000; display: flex; align-items: flex-end; }
  286. .picker-popup { width: 100%; background: #fff; border-radius: 32rpx 32rpx 0 0; padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx); animation: slideUp 0.15s ease-out; }
  287. @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  288. .popup-header { display: flex; justify-content: space-between; align-items: center; padding: 30rpx 40rpx; border-bottom: 1rpx solid #f0f0f0; }
  289. .popup-title { font-size: 32rpx; font-weight: bold; color: #333; }
  290. .cancel-text, .confirm-text { font-size: 30rpx; padding: 10rpx; }
  291. .confirm-text { color: #C1001C; font-weight: bold; }
  292. .item-list { max-height: 50vh; padding: 0 40rpx; }
  293. .option-item { height: 110rpx; display: flex; align-items: center; justify-content: space-between; border-bottom: 1rpx solid #f8f8f8; font-size: 32rpx; color: #333; }
  294. .option-item.active { color: #C1001C; font-weight: bold; }
  295. .bottom-placeholder { height: 60rpx; }
  296. </style>