apply-form.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. <template>
  2. <view class="page">
  3. <NavBar :title="pageTitle" :showBack="true" />
  4. <scroll-view class="form-scroll" scroll-y>
  5. <view class="form-section">
  6. <view class="section-title">
  7. <text class="section-title-text">基本信息</text>
  8. </view>
  9. <view class="form-item required">
  10. <text class="form-label">商品名称</text>
  11. <view class="form-input-wrap">
  12. <input
  13. class="form-input"
  14. v-model="formData.productName"
  15. placeholder="请输入商品名称"
  16. :maxlength="50"
  17. :disabled="isView"
  18. />
  19. </view>
  20. </view>
  21. <view class="form-item required">
  22. <text class="form-label">条形码</text>
  23. <view class="form-input-wrap">
  24. <input
  25. class="form-input"
  26. v-model="formData.barcode"
  27. placeholder="请输入条形码"
  28. :maxlength="30"
  29. :disabled="isView"
  30. @blur="onBarcodeBlur"
  31. />
  32. <view v-if="!isView" class="scan-btn" @click="scanBarcode">
  33. <view class="scan-icon"></view>
  34. </view>
  35. </view>
  36. <text v-if="barcodeWarning" class="form-warning">该条码已存在商品库中</text>
  37. </view>
  38. <view class="form-item">
  39. <text class="form-label">分类</text>
  40. <view class="form-input-wrap">
  41. <input
  42. class="form-input"
  43. v-model="formData.category"
  44. placeholder="请输入分类"
  45. :maxlength="20"
  46. :disabled="isView"
  47. />
  48. </view>
  49. </view>
  50. <view class="form-item">
  51. <text class="form-label">品牌</text>
  52. <view class="form-input-wrap">
  53. <input
  54. class="form-input"
  55. v-model="formData.brand"
  56. placeholder="请输入品牌"
  57. :maxlength="30"
  58. :disabled="isView"
  59. />
  60. </view>
  61. </view>
  62. <view class="form-item">
  63. <text class="form-label">规格</text>
  64. <view class="form-input-wrap">
  65. <input
  66. class="form-input"
  67. v-model="formData.specification"
  68. placeholder="请输入规格"
  69. :maxlength="30"
  70. :disabled="isView"
  71. />
  72. </view>
  73. </view>
  74. <view class="form-item">
  75. <text class="form-label">单位</text>
  76. <view class="form-input-wrap">
  77. <input
  78. class="form-input"
  79. v-model="formData.unit"
  80. placeholder="请输入单位"
  81. :maxlength="10"
  82. :disabled="isView"
  83. />
  84. </view>
  85. </view>
  86. </view>
  87. <view class="form-section">
  88. <view class="section-title">
  89. <text class="section-title-text">价格信息</text>
  90. </view>
  91. <view class="form-item">
  92. <text class="form-label">售价(元)</text>
  93. <view class="form-input-wrap">
  94. <input
  95. class="form-input"
  96. type="digit"
  97. :value="priceInputs.price"
  98. placeholder="请输入售价"
  99. :disabled="isView"
  100. @input="onPriceInput('price', $event)"
  101. @blur="onPriceBlur('price')"
  102. />
  103. </view>
  104. </view>
  105. <view class="form-item">
  106. <text class="form-label">成本价(元)</text>
  107. <view class="form-input-wrap">
  108. <input
  109. class="form-input"
  110. type="digit"
  111. :value="priceInputs.costPrice"
  112. placeholder="请输入成本价"
  113. :disabled="isView"
  114. @input="onPriceInput('costPrice', $event)"
  115. @blur="onPriceBlur('costPrice')"
  116. />
  117. </view>
  118. </view>
  119. </view>
  120. <view class="form-section">
  121. <view class="section-title">
  122. <text class="section-title-text">加工图(5张,按顺序上传)</text>
  123. </view>
  124. <view class="image-upload-area">
  125. <view class="labeled-image-list">
  126. <view class="labeled-image-item" v-for="(item, index) in processedImageSlots" :key="'p'+index">
  127. <text class="labeled-image-title">{{ item.label }}</text>
  128. <view class="label-image-wrap">
  129. <image
  130. v-if="item.url"
  131. class="upload-image"
  132. :src="item.url"
  133. mode="aspectFill"
  134. @click="previewLabeledImage(item.url)"
  135. />
  136. <view v-else-if="!isView" class="image-add" @click="chooseLabeledImage(index, 'processed')">
  137. <text class="add-icon">+</text>
  138. </view>
  139. </view>
  140. <view v-if="!isView && item.url" class="label-image-delete" @click="removeLabeledImage(index, 'processed')">
  141. <text class="delete-icon">×</text>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. </view>
  147. <view class="form-section">
  148. <view class="section-title">
  149. <text class="section-title-text">原图(4张,按顺序上传)</text>
  150. </view>
  151. <view class="image-upload-area">
  152. <view class="labeled-image-list">
  153. <view class="labeled-image-item" v-for="(item, index) in originalImageSlots" :key="'o'+index">
  154. <text class="labeled-image-title">{{ item.label }}</text>
  155. <view class="label-image-wrap">
  156. <image
  157. v-if="item.url"
  158. class="upload-image"
  159. :src="item.url"
  160. mode="aspectFill"
  161. @click="previewLabeledImage(item.url)"
  162. />
  163. <view v-else-if="!isView" class="image-add" @click="chooseLabeledImage(index, 'original')">
  164. <text class="add-icon">+</text>
  165. </view>
  166. </view>
  167. <view v-if="!isView && item.url" class="label-image-delete" @click="removeLabeledImage(index, 'original')">
  168. <text class="delete-icon">×</text>
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 货道参数 -->
  175. <view class="form-section">
  176. <view class="section-title">
  177. <text class="section-title-text">货道参数</text>
  178. </view>
  179. <view class="form-row">
  180. <view class="form-item form-item-half">
  181. <text class="form-label">长度(mm)</text>
  182. <view class="form-input-wrap">
  183. <input class="form-input" type="number" v-model.number="formData.length" placeholder="长度" :disabled="isView" />
  184. </view>
  185. </view>
  186. <view class="form-item form-item-half">
  187. <text class="form-label">宽度(mm)</text>
  188. <view class="form-input-wrap">
  189. <input class="form-input" type="number" v-model.number="formData.width" placeholder="宽度" :disabled="isView" />
  190. </view>
  191. </view>
  192. </view>
  193. <view class="form-row">
  194. <view class="form-item form-item-half">
  195. <text class="form-label">高度(mm)</text>
  196. <view class="form-input-wrap">
  197. <input class="form-input" type="number" v-model.number="formData.height" placeholder="高度" :disabled="isView" />
  198. </view>
  199. </view>
  200. <view class="form-item form-item-half">
  201. <text class="form-label">陈列高度(mm)</text>
  202. <view class="form-input-wrap">
  203. <input class="form-input" type="number" v-model.number="formData.exhibitHeight" placeholder="陈列高度" :disabled="isView" />
  204. </view>
  205. </view>
  206. </view>
  207. <view class="form-row">
  208. <view class="form-item form-item-half">
  209. <text class="form-label">商品占列</text>
  210. <view class="form-input-wrap">
  211. <input class="form-input" type="number" v-model.number="formData.columns" placeholder="占列数" :disabled="isView" />
  212. </view>
  213. </view>
  214. <view class="form-item form-item-half">
  215. <text class="form-label">每货道数量</text>
  216. <view class="form-input-wrap">
  217. <input class="form-input" type="number" v-model.number="formData.numbers" placeholder="数量" :disabled="isView" />
  218. </view>
  219. </view>
  220. </view>
  221. </view>
  222. <!-- 其他信息 -->
  223. <view class="form-section">
  224. <view class="section-title">
  225. <text class="section-title-text">其他信息</text>
  226. </view>
  227. <view class="form-item">
  228. <text class="form-label">商品类型</text>
  229. <view class="form-input-wrap">
  230. <picker :range="productTypeOptions" :range-key="'label'" :value="formData.productType || 0" @change="onProductTypeChange" :disabled="isView">
  231. <text class="picker-value" :class="{ 'picker-placeholder': formData.productType === undefined }">
  232. {{ productTypeLabel }}
  233. </text>
  234. </picker>
  235. </view>
  236. </view>
  237. <view class="form-item">
  238. <text class="form-label">标品/非标品</text>
  239. <view class="form-input-wrap">
  240. <picker :range="standardOptions" :range-key="'label'" :value="formData.standard ? formData.standard - 1 : 0" @change="onStandardChange" :disabled="isView">
  241. <text class="picker-value" :class="{ 'picker-placeholder': formData.standard === undefined }">
  242. {{ standardLabel }}
  243. </text>
  244. </picker>
  245. </view>
  246. </view>
  247. <view class="form-item">
  248. <text class="form-label">学习机号</text>
  249. <view class="form-input-wrap">
  250. <input class="form-input" v-model="formData.stickerNum" placeholder="请输入学习机号" :maxlength="20" :disabled="isView" />
  251. </view>
  252. </view>
  253. <view class="form-item textarea-item">
  254. <text class="form-label">申请原因</text>
  255. <textarea
  256. class="form-textarea"
  257. v-model="formData.reason"
  258. placeholder="请输入申请原因"
  259. :maxlength="500"
  260. :disabled="isView"
  261. auto-height
  262. :style="{ minHeight: '120rpx' }"
  263. />
  264. <text v-if="!isView" class="char-count">{{ (formData.reason || '').length }}/500</text>
  265. </view>
  266. </view>
  267. <view class="form-section">
  268. <view class="section-title">
  269. <text class="section-title-text">商品描述</text>
  270. </view>
  271. <view class="form-item textarea-item">
  272. <textarea
  273. class="form-textarea"
  274. v-model="formData.description"
  275. placeholder="请输入商品描述"
  276. :maxlength="500"
  277. :disabled="isView"
  278. auto-height
  279. :style="{ minHeight: '160rpx' }"
  280. />
  281. <text v-if="!isView" class="char-count">{{ (formData.description || '').length }}/500</text>
  282. </view>
  283. </view>
  284. <view class="bottom-spacer"></view>
  285. </scroll-view>
  286. <view class="footer-bar" v-if="!isView">
  287. <view class="btn-draft" @click="handleSaveDraft" v-if="!isEdit">
  288. <text class="btn-draft-text">存草稿</text>
  289. </view>
  290. <view class="btn-submit" @click="handleSubmit">
  291. <text class="btn-submit-text">{{ isEdit ? '保存修改' : '提交申请' }}</text>
  292. </view>
  293. </view>
  294. </view>
  295. </template>
  296. <script setup lang="ts">
  297. import { ref, reactive, computed, onMounted } from 'vue';
  298. import NavBar from '@/components/NavBar.vue';
  299. import {
  300. getNewProductApplyById,
  301. submitNewProductApply,
  302. saveNewProductApplyDraft,
  303. updateNewProductApply,
  304. checkBarcode,
  305. type NewProductApplyItem
  306. } from '@/api/newProductApply';
  307. import { showToast } from '@/utils/common';
  308. import { UPLOAD_URL, IMAGE_BASE_URL } from '@/utils/config';
  309. type PageMode = 'add' | 'edit' | 'view';
  310. const mode = ref<PageMode>('add');
  311. const editId = ref<number>(0);
  312. const barcodeWarning = ref(false);
  313. // 商品类型选项
  314. const productTypeOptions = [{ label: '静态', value: 0 }, { label: '动态', value: 1 }];
  315. const standardOptions = [{ label: '标品', value: 1 }, { label: '非标品', value: 2 }];
  316. const productTypeLabel = computed(() => {
  317. const opt = productTypeOptions.find(o => o.value === formData.productType);
  318. return opt ? opt.label : '请选择商品类型';
  319. });
  320. const standardLabel = computed(() => {
  321. const opt = standardOptions.find(o => o.value === formData.standard);
  322. return opt ? opt.label : '请选择';
  323. });
  324. // 9张分类图片 slots
  325. const processedLabels = ['正面图', '背面图', '侧面图', '顶部图', '称重图'];
  326. const originalLabels = ['正面原图', '背面原图', '侧面原图', '顶部原图'];
  327. const processedImageSlots = ref(processedLabels.map(label => ({ label, url: '' })));
  328. const originalImageSlots = ref(originalLabels.map(label => ({ label, url: '' })));
  329. const isEdit = computed(() => mode.value === 'edit');
  330. const isView = computed(() => mode.value === 'view');
  331. const pageTitle = computed(() => {
  332. if (isView.value) return '查看申请';
  333. if (isEdit.value) return '编辑申请';
  334. return '新品申请';
  335. });
  336. const formData = reactive<NewProductApplyItem>({
  337. productName: '',
  338. barcode: '',
  339. category: '',
  340. brand: '',
  341. specification: '',
  342. unit: '',
  343. price: 0,
  344. costPrice: 0,
  345. images: '',
  346. description: '',
  347. productType: 0,
  348. standard: 1,
  349. stickerNum: '',
  350. length: undefined,
  351. width: undefined,
  352. height: undefined,
  353. exhibitHeight: undefined,
  354. columns: undefined,
  355. numbers: undefined,
  356. reason: ''
  357. });
  358. const validate = (): string | null => {
  359. if (!formData.productName.trim()) {
  360. return '请输入商品名称';
  361. }
  362. if (!formData.barcode.trim()) {
  363. return '请输入条形码';
  364. }
  365. return null;
  366. };
  367. const priceInputs = reactive({ price: '', costPrice: '' });
  368. const initPriceInputs = () => {
  369. priceInputs.price = formData.price ? String(formData.price) : '';
  370. priceInputs.costPrice = formData.costPrice ? String(formData.costPrice) : '';
  371. };
  372. const onPriceInput = (field: 'price' | 'costPrice', e: any) => {
  373. let val = e.detail.value;
  374. val = val.replace(/[^\d.]/g, '');
  375. if (val.startsWith('.')) val = '0' + val;
  376. const parts = val.split('.');
  377. if (parts.length > 1) {
  378. val = parts[0] + '.' + parts.slice(1).join('').slice(0, 2);
  379. }
  380. if (parts.length > 2) {
  381. val = parts[0] + '.' + parts[1];
  382. }
  383. priceInputs[field] = val;
  384. };
  385. const onPriceBlur = (field: 'price' | 'costPrice') => {
  386. const val = parseFloat(priceInputs[field]);
  387. formData[field] = isNaN(val) ? 0 : Math.max(0, parseFloat(val.toFixed(2)));
  388. priceInputs[field] = formData[field] ? String(formData[field]) : '';
  389. };
  390. const scanBarcode = () => {
  391. uni.scanCode({
  392. scanType: ['barCode'],
  393. success: (res) => {
  394. if (res.result) {
  395. formData.barcode = res.result;
  396. onBarcodeBlur();
  397. }
  398. },
  399. fail: () => {
  400. showToast('扫码取消或失败');
  401. }
  402. });
  403. };
  404. const onBarcodeBlur = async () => {
  405. if (!formData.barcode.trim()) {
  406. barcodeWarning.value = false;
  407. return;
  408. }
  409. try {
  410. const res = await checkBarcode(formData.barcode.trim());
  411. if (res && res.exists) {
  412. barcodeWarning.value = true;
  413. if (res.product) {
  414. formData.productName = res.product.productName || formData.productName;
  415. formData.category = res.product.category || formData.category;
  416. formData.brand = res.product.brand || formData.brand;
  417. formData.specification = res.product.specification || formData.specification;
  418. formData.unit = res.product.unit || formData.unit;
  419. formData.price = res.product.price || formData.price;
  420. }
  421. } else {
  422. barcodeWarning.value = false;
  423. }
  424. } catch (error) {
  425. barcodeWarning.value = false;
  426. }
  427. };
  428. const onProductTypeChange = (e: any) => {
  429. formData.productType = productTypeOptions[e.detail.value].value;
  430. };
  431. const onStandardChange = (e: any) => {
  432. formData.standard = standardOptions[e.detail.value].value;
  433. };
  434. // 分类图片上传
  435. const chooseLabeledImage = (index: number, type: 'processed' | 'original') => {
  436. uni.chooseImage({
  437. count: 1,
  438. sizeType: ['compressed'],
  439. sourceType: ['album', 'camera'],
  440. success: async (res) => {
  441. const tempPath = res.tempFilePaths[0];
  442. try {
  443. const uploadedUrl = await uploadImage(tempPath);
  444. if (type === 'processed') {
  445. processedImageSlots.value[index].url = uploadedUrl;
  446. } else {
  447. originalImageSlots.value[index].url = uploadedUrl;
  448. }
  449. syncImagesToForm();
  450. } catch (error) {
  451. console.error('上传图片失败', error);
  452. }
  453. }
  454. });
  455. };
  456. const removeLabeledImage = (index: number, type: 'processed' | 'original') => {
  457. if (type === 'processed') {
  458. processedImageSlots.value[index].url = '';
  459. } else {
  460. originalImageSlots.value[index].url = '';
  461. }
  462. syncImagesToForm();
  463. };
  464. const previewLabeledImage = (url: string) => {
  465. uni.previewImage({
  466. current: url.startsWith('http') ? url : `${IMAGE_BASE_URL}${url}`,
  467. urls: [url.startsWith('http') ? url : `${IMAGE_BASE_URL}${url}`]
  468. });
  469. };
  470. const syncImagesToForm = () => {
  471. const allUrls = [
  472. ...processedImageSlots.value.map(s => s.url),
  473. ...originalImageSlots.value.map(s => s.url)
  474. ];
  475. formData.images = allUrls.join(',');
  476. };
  477. const uploadImage = (tempFilePath: string): Promise<string> => {
  478. return new Promise((resolve, reject) => {
  479. uni.uploadFile({
  480. url: UPLOAD_URL,
  481. filePath: tempFilePath,
  482. name: 'file',
  483. success: (uploadRes) => {
  484. try {
  485. const data = JSON.parse(uploadRes.data);
  486. if (data.code === 200 && data.data) {
  487. const url = data.data.url || data.data;
  488. resolve(url.startsWith('http') ? url : `${IMAGE_BASE_URL}${url}`);
  489. } else {
  490. reject(new Error(data.message || '上传失败'));
  491. }
  492. } catch {
  493. reject(new Error('解析上传结果失败'));
  494. }
  495. },
  496. fail: (err) => {
  497. reject(err);
  498. }
  499. });
  500. });
  501. };
  502. const handleSaveDraft = async () => {
  503. const error = validate();
  504. if (error) {
  505. showToast(error);
  506. return;
  507. }
  508. try {
  509. uni.showLoading({ title: '保存中...', mask: true });
  510. await saveNewProductApplyDraft(formData);
  511. uni.hideLoading();
  512. showToast('草稿保存成功', 'success');
  513. setTimeout(() => {
  514. uni.navigateBack();
  515. }, 500);
  516. } catch (error) {
  517. uni.hideLoading();
  518. console.error('保存草稿失败', error);
  519. }
  520. };
  521. const handleSubmit = async () => {
  522. const error = validate();
  523. if (error) {
  524. showToast(error);
  525. return;
  526. }
  527. try {
  528. uni.showLoading({ title: '提交中...', mask: true });
  529. if (isEdit.value) {
  530. await updateNewProductApply(editId.value, formData);
  531. showToast('修改成功', 'success');
  532. } else {
  533. await submitNewProductApply(formData);
  534. showToast('提交成功', 'success');
  535. }
  536. uni.hideLoading();
  537. setTimeout(() => {
  538. uni.navigateBack();
  539. }, 500);
  540. } catch (error) {
  541. uni.hideLoading();
  542. console.error('提交失败', error);
  543. }
  544. };
  545. const loadDetail = async (id: number) => {
  546. try {
  547. uni.showLoading({ title: '加载中...', mask: true });
  548. const res: any = await getNewProductApplyById(id);
  549. uni.hideLoading();
  550. if (res) {
  551. Object.assign(formData, {
  552. productName: res.productName || res.name || '',
  553. barcode: res.barcode || '',
  554. category: res.category || '',
  555. brand: res.brand || '',
  556. specification: res.specification || '',
  557. unit: res.unit || '',
  558. price: res.price || 0,
  559. costPrice: res.costPrice || res.cost || 0,
  560. images: res.images || '',
  561. description: res.description || '',
  562. productType: res.productType ?? 0,
  563. standard: res.standard ?? 1,
  564. stickerNum: res.stickerNum || '',
  565. length: res.length ?? undefined,
  566. width: res.width ?? undefined,
  567. height: res.height ?? undefined,
  568. exhibitHeight: res.exhibitHeight ?? undefined,
  569. columns: res.columns ?? undefined,
  570. numbers: res.numbers ?? undefined,
  571. reason: res.reason || ''
  572. });
  573. initPriceInputs();
  574. // 解析图片到分类slots:优先从独立字段,其次从逗号分隔字符串
  575. const allUrls: string[] = [];
  576. const directFields = [res.imageUrl, res.imageUrl2, res.imageUrl3, res.imageUrl4, res.imageUrl5,
  577. res.originalImageUrl1, res.originalImageUrl2, res.originalImageUrl3, res.originalImageUrl4];
  578. const hasDirect = directFields.some((f: string) => f);
  579. if (hasDirect) {
  580. for (const f of directFields) allUrls.push(f || '');
  581. } else if (res.images) {
  582. const parts = res.images.split(',');
  583. for (const p of parts) allUrls.push((p || '').trim());
  584. }
  585. for (let i = 0; i < 5 && i < allUrls.length; i++) {
  586. processedImageSlots.value[i].url = allUrls[i] || '';
  587. }
  588. for (let i = 0; i < 4 && i < allUrls.length - 5; i++) {
  589. originalImageSlots.value[i].url = allUrls[5 + i] || '';
  590. }
  591. }
  592. } catch (error) {
  593. uni.hideLoading();
  594. console.error('加载详情失败', error);
  595. }
  596. };
  597. onMounted(() => {
  598. const pages = getCurrentPages();
  599. const currentPage = pages[pages.length - 1] as any;
  600. const options = currentPage?.options || {};
  601. const id = options.id ? Number(options.id) : 0;
  602. const pageMode = options.mode || '';
  603. if (id) {
  604. editId.value = id;
  605. if (pageMode === 'view') {
  606. mode.value = 'view';
  607. } else {
  608. mode.value = 'edit';
  609. }
  610. loadDetail(id);
  611. }
  612. });
  613. </script>
  614. <style lang="scss" scoped>
  615. .page {
  616. min-height: 100vh;
  617. background: $bg-color-page;
  618. display: flex;
  619. flex-direction: column;
  620. }
  621. .form-scroll {
  622. flex: 1;
  623. padding: 24rpx;
  624. height: 0;
  625. }
  626. .form-section {
  627. background: $bg-color-card;
  628. border-radius: $radius-lg;
  629. padding: 0 24rpx;
  630. margin-bottom: 20rpx;
  631. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  632. }
  633. .section-title {
  634. padding: 28rpx 0 12rpx;
  635. }
  636. .section-title-text {
  637. font-size: $font-size-base;
  638. font-weight: 600;
  639. color: $text-color-primary;
  640. }
  641. .form-item {
  642. padding: 18rpx 0;
  643. &.required .form-label::before {
  644. content: '*';
  645. color: $error-color;
  646. margin-right: 6rpx;
  647. }
  648. &.textarea-item {
  649. padding-bottom: 20rpx;
  650. }
  651. }
  652. .form-label {
  653. font-size: $font-size-sm;
  654. color: $text-color-secondary;
  655. margin-bottom: 12rpx;
  656. display: block;
  657. }
  658. .form-input-wrap {
  659. display: flex;
  660. align-items: center;
  661. background: #FAFAFA;
  662. border-radius: $radius-base;
  663. padding: 0 20rpx;
  664. height: 80rpx;
  665. }
  666. .form-input {
  667. flex: 1;
  668. height: 80rpx;
  669. font-size: $font-size-base;
  670. color: $text-color-primary;
  671. }
  672. .scan-btn {
  673. width: 60rpx;
  674. height: 60rpx;
  675. display: flex;
  676. align-items: center;
  677. justify-content: center;
  678. margin-left: 12rpx;
  679. border-radius: $radius-base;
  680. background: $primary-color-bg;
  681. &:active { opacity: 0.7; }
  682. }
  683. .scan-icon {
  684. width: 36rpx;
  685. height: 30rpx;
  686. border: 3rpx solid $primary-color;
  687. border-radius: 4rpx;
  688. position: relative;
  689. &::after {
  690. content: '';
  691. position: absolute;
  692. top: -8rpx;
  693. right: -8rpx;
  694. width: 12rpx;
  695. height: 3rpx;
  696. background: $primary-color;
  697. border-radius: 2rpx;
  698. }
  699. }
  700. .form-warning {
  701. font-size: $font-size-xs;
  702. color: $warning-color;
  703. margin-top: 8rpx;
  704. display: block;
  705. }
  706. .form-textarea {
  707. width: 100%;
  708. background: #FAFAFA;
  709. border-radius: $radius-base;
  710. padding: 20rpx;
  711. font-size: $font-size-base;
  712. color: $text-color-primary;
  713. box-sizing: border-box;
  714. }
  715. .char-count {
  716. display: block;
  717. text-align: right;
  718. font-size: $font-size-xs;
  719. color: $text-color-muted;
  720. margin-top: 8rpx;
  721. }
  722. .image-upload-area {
  723. padding: 20rpx 0;
  724. }
  725. .labeled-image-list {
  726. display: flex;
  727. flex-wrap: wrap;
  728. gap: 16rpx;
  729. }
  730. .labeled-image-item {
  731. position: relative;
  732. display: flex;
  733. flex-direction: column;
  734. align-items: center;
  735. gap: 8rpx;
  736. }
  737. .labeled-image-title {
  738. font-size: 22rpx;
  739. color: $text-color-muted;
  740. }
  741. .label-image-wrap {
  742. width: 150rpx;
  743. height: 150rpx;
  744. border-radius: $radius-base;
  745. overflow: hidden;
  746. background: #FAFAFA;
  747. }
  748. .label-image-wrap .upload-image {
  749. width: 150rpx;
  750. height: 150rpx;
  751. border-radius: $radius-base;
  752. background: $bg-color-page;
  753. }
  754. .label-image-wrap .image-add {
  755. width: 150rpx;
  756. height: 150rpx;
  757. display: flex;
  758. align-items: center;
  759. justify-content: center;
  760. background: #FAFAFA;
  761. &:active { opacity: 0.8; }
  762. }
  763. .label-image-delete {
  764. position: absolute;
  765. top: 18rpx;
  766. right: 2rpx;
  767. width: 36rpx;
  768. height: 36rpx;
  769. background: $error-color;
  770. border-radius: 50%;
  771. display: flex;
  772. align-items: center;
  773. justify-content: center;
  774. }
  775. .image-list {
  776. display: flex;
  777. flex-wrap: wrap;
  778. gap: 16rpx;
  779. }
  780. .image-item {
  781. position: relative;
  782. width: 200rpx;
  783. height: 200rpx;
  784. }
  785. .upload-image {
  786. width: 200rpx;
  787. height: 200rpx;
  788. border-radius: $radius-base;
  789. background: $bg-color-page;
  790. }
  791. .image-delete {
  792. position: absolute;
  793. top: -12rpx;
  794. right: -12rpx;
  795. width: 40rpx;
  796. height: 40rpx;
  797. background: $error-color;
  798. border-radius: 50%;
  799. display: flex;
  800. align-items: center;
  801. justify-content: center;
  802. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
  803. }
  804. .delete-icon {
  805. font-size: 28rpx;
  806. color: #fff;
  807. line-height: 1;
  808. }
  809. .image-add {
  810. width: 200rpx;
  811. height: 200rpx;
  812. border-radius: $radius-base;
  813. display: flex;
  814. flex-direction: column;
  815. align-items: center;
  816. justify-content: center;
  817. background: #FAFAFA;
  818. &:active {
  819. opacity: 0.8;
  820. }
  821. }
  822. .add-icon {
  823. font-size: 56rpx;
  824. color: $text-color-muted;
  825. line-height: 1;
  826. }
  827. .add-text {
  828. font-size: $font-size-xs;
  829. color: $text-color-muted;
  830. margin-top: 8rpx;
  831. }
  832. .image-tip {
  833. font-size: $font-size-xs;
  834. color: $text-color-placeholder;
  835. margin-top: 12rpx;
  836. display: block;
  837. }
  838. // 货道参数双列布局
  839. .form-row {
  840. display: flex;
  841. gap: 20rpx;
  842. }
  843. .form-item-half {
  844. flex: 1;
  845. min-width: 0;
  846. }
  847. // picker 文本样式
  848. .picker-value {
  849. font-size: $font-size-base;
  850. color: $text-color-primary;
  851. }
  852. .picker-placeholder {
  853. color: $text-color-placeholder;
  854. }
  855. .bottom-spacer {
  856. height: 140rpx;
  857. }
  858. .footer-bar {
  859. position: fixed;
  860. left: 0;
  861. right: 0;
  862. bottom: 0;
  863. display: flex;
  864. gap: 20rpx;
  865. padding: 20rpx 24rpx;
  866. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  867. background: $bg-color-card;
  868. border-top: 1rpx solid $border-color;
  869. z-index: 100;
  870. }
  871. .btn-draft {
  872. flex: 1;
  873. height: 88rpx;
  874. display: flex;
  875. align-items: center;
  876. justify-content: center;
  877. border-radius: $radius-full;
  878. border: 2rpx solid $border-color;
  879. &:active { opacity: 0.7; }
  880. }
  881. .btn-draft-text {
  882. font-size: $font-size-lg;
  883. color: $text-color-secondary;
  884. font-weight: 500;
  885. }
  886. .btn-submit {
  887. flex: 2;
  888. height: 88rpx;
  889. display: flex;
  890. align-items: center;
  891. justify-content: center;
  892. background: $primary-color;
  893. border-radius: $radius-full;
  894. &:active { opacity: 0.8; }
  895. }
  896. .btn-submit-text {
  897. font-size: $font-size-lg;
  898. color: $text-color-primary;
  899. font-weight: 600;
  900. }
  901. </style>