pageFour.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. <template>
  2. <view class="page-container">
  3. <!-- 入库信息卡片 -->
  4. <view class="card_wrap">
  5. <u--form labelPosition="top" :model="warehouseInfo" :rules="rules" ref="form" class="address-section">
  6. <view class="address-header">
  7. <u-icon name="car-fill" size="36rpx" color="#108cff" class="location-icon"></u-icon>
  8. <text class="address-title">入库信息</text>
  9. </view>
  10. <!-- 编码和快递单号同一行 -->
  11. <u-row class="info-row" justify="space-between">
  12. <u-col span="4.5">
  13. <u-form-item label="编码" prop="accountHolder">
  14. <u--input v-model="warehouseInfo.accountHolder" placeholder="请输入编码" class="info-input" />
  15. </u-form-item>
  16. </u-col>
  17. <u-col span="4.5">
  18. <u-form-item label="快递单号" prop="bankName">
  19. <u--input v-model="warehouseInfo.bankName" placeholder="请输入快递单号" class="info-input" />
  20. </u-form-item>
  21. </u-col>
  22. <u-col span="2">
  23. <u-form-item label="物流图片" prop="uploadedImage">
  24. <view class="image-uploader" @click="selectImage">
  25. <u-icon v-if="!warehouseInfo.uploadedImage" name="camera-fill" size="48rpx"
  26. color="#909399" class="camera-icon"></u-icon>
  27. <image v-else :src="warehouseInfo.uploadedImage" mode="aspectFill"
  28. class="image-preview">
  29. </image>
  30. </view>
  31. </u-form-item>
  32. </u-col>
  33. </u-row>
  34. <!-- 单独一行的收单物品 -->
  35. <u-row class="info-row">
  36. <u-col span="12">
  37. <u-form-item label="收单物品" prop="item">
  38. <u--input v-model="warehouseInfo.item" placeholder="请输入收单物品" class="info-input" />
  39. </u-form-item>
  40. </u-col>
  41. </u-row>
  42. <!-- 查码费和表款同一行 -->
  43. <u-row class="info-row" justify="space-between">
  44. <u-col span="5.8">
  45. <u-form-item label="查码费">
  46. <u--input v-model="warehouseInfo.checkCodeFee" placeholder="请输入查码费" class="info-input"
  47. type="number" />
  48. </u-form-item>
  49. </u-col>
  50. <u-col span="5.8">
  51. <u-form-item label="表款">
  52. <u--input v-model="warehouseInfo.tableFee" placeholder="请输入表款" class="info-input"
  53. type="number" />
  54. </u-form-item>
  55. </u-col>
  56. </u-row>
  57. <!-- 维修金额和毛业绩同一行 -->
  58. <u-row class="info-row" justify="space-between">
  59. <u-col span="5.8">
  60. <u-form-item label="维修金额">
  61. <u--input v-model="warehouseInfo.repairAmount" placeholder="请输入维修金额" class="info-input"
  62. type="number" />
  63. </u-form-item>
  64. </u-col>
  65. <u-col span="5.8">
  66. <u-form-item label="毛业绩">
  67. <u--input v-model="warehouseInfo.grossPerformance" placeholder="请输入毛业绩" class="info-input"
  68. type="number" />
  69. </u-form-item>
  70. </u-col>
  71. </u-row>
  72. <!-- 收单备注 -->
  73. <u-row class="info-row">
  74. <u-col span="12">
  75. <u-form-item label="收单备注">
  76. <u--textarea v-model="warehouseInfo.remarks" placeholder="请输入收单备注" class="info-input"
  77. confirmType="done" rows="4" />
  78. </u-form-item>
  79. </u-col>
  80. </u-row>
  81. </u--form>
  82. </view>
  83. <!-- 新添加的卡片 -->
  84. <view class="card_wrap">
  85. <view class="address-section">
  86. <view class="address-header">
  87. <u-icon name="list" size="36rpx" color="#108cff" class="location-icon"></u-icon>
  88. <text class="address-title">分成信息</text>
  89. <u-button type="primary" plain shape="circle" size="mini" class="add-button" @click="addSplit">
  90. <u-icon name="plus" size="24rpx" color="#108cff"></u-icon>
  91. <text>添加</text>
  92. </u-button>
  93. </view>
  94. <!-- 分成信息表格 -->
  95. <view class="split-table">
  96. <u-row class="split-table-header">
  97. <u-col span="2">
  98. <text class="header-text">关联</text>
  99. </u-col>
  100. <u-col span="2">
  101. <text class="header-text">账户类型</text>
  102. </u-col>
  103. <u-col span="2">
  104. <text class="header-text">分成人</text>
  105. </u-col>
  106. <u-col span="2">
  107. <text class="header-text">比例(%)</text>
  108. </u-col>
  109. <u-col span="2">
  110. <text class="header-text">归属公司</text>
  111. </u-col>
  112. <u-col span="2" class="action-column">
  113. <text class="header-text">操作</text>
  114. </u-col>
  115. </u-row>
  116. <u-row v-for="(item, index) in profitSharingList" :key="item.id" class="split-table-row">
  117. <u-col span="2">
  118. <view class="table-cell">
  119. <select v-model="item.association" class="custom-select">
  120. <option value="">无</option>
  121. <option v-for="option in associationOptions" :key="option" :value="option">
  122. {{ option }}
  123. </option>
  124. </select>
  125. </view>
  126. </u-col>
  127. <u-col span="2">
  128. <view class="table-cell">
  129. <view
  130. :class="['account-type', item.accountType === 'frontend' ? 'frontend' : 'backend']"
  131. @click="toggleAccountType(item)" style="cursor: pointer;">
  132. {{ item.accountType === 'frontend' ? '前' : '后' }}
  133. </view>
  134. </view>
  135. </u-col>
  136. <u-col span="2">
  137. <view class="table-cell">
  138. <select v-model="item.person" class="custom-select">
  139. <option value="">无</option>
  140. <option v-for="person in personOptions" :key="person" :value="person">
  141. {{ person }}
  142. </option>
  143. </select>
  144. </view>
  145. </u-col>
  146. <u-col span="2">
  147. <view class="table-cell">
  148. <u--input v-model="item.percentage" type="number" class="percentage-input"
  149. @input="handlePercentageInput(item)" min="0" max="100" precision="0" />
  150. </view>
  151. </u-col>
  152. <u-col span="2">
  153. <view class="table-cell">
  154. <view class="radio-wrapper" @click="toggleBelongToCompany(item)">
  155. <view :class="['radio-circle', item.belongToCompany ? 'active' : '']">
  156. <u-icon v-if="item.belongToCompany" name="checkmark" size="20rpx"
  157. color="#fff"></u-icon>
  158. </view>
  159. </view>
  160. </view>
  161. </u-col>
  162. <u-col span="2" class="action-column">
  163. <view class="table-cell">
  164. <u-button type="error" plain shape="circle" size="mini" @click="deleteSplit(index)"
  165. :disabled="profitSharingList.length <= 1">
  166. <u-icon name="trash" size="20rpx" color="#ff6b6b"></u-icon>
  167. </u-button>
  168. </view>
  169. </u-col>
  170. </u-row>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 确认入库按钮 -->
  175. <div class="confirm-button-container">
  176. <u-button type="success" @click="confirmWarehouseEntry" style="border-radius: 11px;">
  177. <u-icon name="checkmark-circle-fill" size="28rpx" color="#fff"></u-icon>
  178. <text style="margin-left: 8rpx;">确认入库</text>
  179. </u-button>
  180. </div>
  181. </view>
  182. </template>
  183. <script>
  184. export default {
  185. data() {
  186. return {
  187. // 入库信息相关的数据
  188. warehouseInfo: {
  189. accountHolder: '',
  190. bankName: '',
  191. item: '',
  192. checkCodeFee: '',
  193. tableFee: '',
  194. repairAmount: '',
  195. grossPerformance: '',
  196. remarks: '',
  197. uploadedImage: ''
  198. },
  199. // 分成信息相关的数据
  200. profitSharingList: [
  201. {
  202. id: Date.now() + '_1', // 唯一ID
  203. association: '', // 关联
  204. accountType: 'frontend', // 账户类型:frontend(前端)/backend(后端)
  205. person: '', // 分成人
  206. percentage: 100, // 分成比例
  207. belongToCompany: false // 归属公司
  208. }
  209. ],
  210. // 关联选项列表
  211. associationOptions: ['选项1', '选项2', '选项3'],
  212. // 分成人选项列表
  213. personOptions: ['人员A', '人员B', '人员C'],
  214. // 表单验证规则
  215. rules: {
  216. accountHolder: {
  217. type: 'string',
  218. required: true,
  219. message: '请输入编码',
  220. trigger: []
  221. },
  222. bankName: {
  223. type: 'string',
  224. required: true,
  225. message: '请输入快递单号',
  226. trigger: []
  227. },
  228. item: {
  229. type: 'string',
  230. required: true,
  231. message: '请输入收单物品',
  232. trigger: []
  233. },
  234. uploadedImage: {
  235. type: 'string',
  236. required: true,
  237. message: '请上传物流图片',
  238. trigger: []
  239. }
  240. }
  241. };
  242. },
  243. methods: {
  244. // 选择图片
  245. selectImage() {
  246. uni.chooseImage({
  247. count: 1,
  248. sizeType: ['original', 'compressed'],
  249. sourceType: ['album', 'camera'],
  250. success: (res) => {
  251. const tempFilePath = res.tempFilePaths[0];
  252. this.warehouseInfo.uploadedImage = tempFilePath;
  253. }
  254. });
  255. },
  256. // 添加分成行
  257. addSplit() {
  258. // 生成唯一ID
  259. const newId = Date.now() + '_' + (this.profitSharingList.length + 1);
  260. // 添加新行
  261. this.profitSharingList.push({
  262. id: newId,
  263. association: '',
  264. accountType: 'frontend',
  265. person: '',
  266. percentage: 0,
  267. belongToCompany: false
  268. });
  269. // 重新计算所有行的比例
  270. this.recalculatePercentage();
  271. },
  272. // 删除分成行
  273. deleteSplit(index) {
  274. if (this.profitSharingList.length <= 1) {
  275. return; // 至少保留一行
  276. }
  277. // 删除对应行
  278. this.profitSharingList.splice(index, 1);
  279. // 重新计算所有行的比例
  280. this.recalculatePercentage();
  281. },
  282. // 重新计算分成比例
  283. recalculatePercentage() {
  284. const totalRows = this.profitSharingList.length;
  285. if (totalRows > 0) {
  286. // 计算平均比例(向下取整)
  287. const avgPercentage = Math.floor(100 / totalRows);
  288. // 设置所有行的比例
  289. this.profitSharingList.forEach(item => {
  290. item.percentage = avgPercentage;
  291. });
  292. }
  293. },
  294. // 切换账户类型
  295. toggleAccountType(item) {
  296. item.accountType = item.accountType === 'frontend' ? 'backend' : 'frontend';
  297. },
  298. // 处理百分比输入
  299. handlePercentageInput(item) {
  300. // 确保输入是数字
  301. let value = Number(item.percentage);
  302. // 验证输入值是否在有效范围内(0-100)
  303. if (isNaN(value)) {
  304. item.percentage = 0;
  305. } else if (value < 0) {
  306. item.percentage = 0;
  307. } else if (value > 100) {
  308. item.percentage = 100;
  309. } else {
  310. // 确保是整数
  311. item.percentage = Math.floor(value);
  312. }
  313. },
  314. // 切换归属公司状态
  315. toggleBelongToCompany(item) {
  316. item.belongToCompany = !item.belongToCompany;
  317. },
  318. // 确认入库方法
  319. confirmWarehouseEntry() {
  320. // 表单校验
  321. this.$refs.form.validate().then(() => {
  322. // 表单验证通过后,进行分成信息的自定义验证
  323. if (this.validateProfitSharing()) {
  324. console.log(this.warehouseInfo, this.profitSharingList);
  325. }
  326. }).catch(() => {
  327. // 表单验证失败,不执行后续操作
  328. });
  329. },
  330. // 分成信息校验方法
  331. validateProfitSharing() {
  332. // 校验分成信息
  333. for (let i = 0; i < this.profitSharingList.length; i++) {
  334. const item = this.profitSharingList[i];
  335. if (!item.person.trim()) {
  336. uni.showToast({
  337. title: `第${i + 1}行请选择分成人`,
  338. icon: 'none'
  339. });
  340. return false;
  341. }
  342. if (item.percentage <= 0 || item.percentage > 100) {
  343. uni.showToast({
  344. title: `第${i + 1}行分成比例必须在1-100之间`,
  345. icon: 'none'
  346. });
  347. return false;
  348. }
  349. }
  350. // 校验分成比例总和,总和必须是100%
  351. // const totalPercentage = this.profitSharingList.reduce((sum, item) => sum + Number(item.percentage), 0);
  352. // if (totalPercentage !== 100) {
  353. // uni.showToast({
  354. // title: '分成比例总和必须为100%',
  355. // icon: 'none'
  356. // });
  357. // return false;
  358. // }
  359. return true;
  360. }
  361. }
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. // 导入公共样式
  366. @import './common.scss';
  367. // 主样式
  368. .page-container {
  369. box-sizing: border-box;
  370. padding: 0;
  371. background-color: map-get($colors, bg);
  372. font-family: map-get($font, family);
  373. -webkit-font-smoothing: map-get($font, smoothing);
  374. font-smoothing: map-get($font, smoothing);
  375. }
  376. .address-section {
  377. padding: map-get($sizes, padding-sm) map-get($sizes, padding);
  378. .u-col {
  379. padding: 0;
  380. box-sizing: border-box;
  381. }
  382. .u-col:first-child {
  383. padding-right: 15rpx;
  384. }
  385. .u-col:last-child {
  386. padding-left: 15rpx;
  387. }
  388. }
  389. // 表单行样式
  390. .info-row {
  391. margin-bottom: 20rpx;
  392. box-sizing: border-box;
  393. padding: 0;
  394. }
  395. // 表单标签样式
  396. .info-label {
  397. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  398. margin-bottom: 8rpx;
  399. display: block;
  400. }
  401. // 输入框样式
  402. .info-input {
  403. height: 65rpx;
  404. border-radius: 8rpx;
  405. border: 1rpx solid #e5e7eb;
  406. padding: 20rpx 16rpx;
  407. width: 100%;
  408. box-sizing: border-box;
  409. @include font-styles($size: small, $weight: regular, $color: secondary);
  410. // textarea特殊样式
  411. &[type="textarea"] {
  412. min-height: 160rpx;
  413. resize: vertical;
  414. padding-top: 20rpx;
  415. padding-bottom: 20rpx;
  416. }
  417. }
  418. // 防止表单label换行
  419. ::v-deep .u-form-item__body__left__content__label {
  420. white-space: nowrap;
  421. }
  422. // 图片上传样式
  423. .image-uploader {
  424. width: 100%;
  425. height: 65rpx;
  426. border: 2rpx dashed #409eff;
  427. border-radius: 8rpx;
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. cursor: pointer;
  432. background-color: #ecf5ff;
  433. box-sizing: border-box;
  434. overflow: hidden;
  435. transition: all 0.3s ease;
  436. &:hover {
  437. border-color: #66b1ff;
  438. background-color: #f0f9ff;
  439. transform: scale(1.02);
  440. }
  441. }
  442. .camera-icon {
  443. margin: 0;
  444. font-size: 32rpx;
  445. color: #409eff;
  446. transition: all 0.3s ease;
  447. }
  448. .image-uploader:hover .camera-icon {
  449. color: #66b1ff;
  450. transform: scale(1.1);
  451. }
  452. .image-preview {
  453. width: 100%;
  454. height: 100%;
  455. object-fit: cover;
  456. border-radius: 10rpx;
  457. box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
  458. transition: all 0.3s ease;
  459. }
  460. .image-uploader:hover .image-preview {
  461. transform: scale(1.02);
  462. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
  463. }
  464. .hidden-input {
  465. display: none;
  466. }
  467. // 分成信息卡片样式
  468. .address-header {
  469. display: flex;
  470. align-items: center;
  471. justify-content: space-between;
  472. margin-bottom: 20rpx;
  473. .address-title {
  474. @include font-styles($size: small, $weight: medium, $color: primary);
  475. margin-left: 10rpx;
  476. }
  477. }
  478. .split-content {
  479. padding: 10rpx 0;
  480. }
  481. .split-item {
  482. display: flex;
  483. justify-content: space-between;
  484. align-items: center;
  485. padding: 15rpx 0;
  486. border-bottom: 1rpx solid map-get($colors, border);
  487. &:last-child {
  488. border-bottom: none;
  489. }
  490. }
  491. .split-label {
  492. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  493. }
  494. .split-value {
  495. @include font-styles($size: small, $weight: regular, $color: secondary);
  496. }
  497. .add-button {
  498. padding: 0;
  499. width: 50rpx;
  500. height: 50rpx;
  501. display: flex;
  502. align-items: center;
  503. justify-content: center;
  504. }
  505. /* 分成信息表格样式 */
  506. .split-table {
  507. width: 100%;
  508. margin-top: 20rpx;
  509. background-color: #fff;
  510. border-radius: 8rpx;
  511. overflow: hidden;
  512. }
  513. .split-table-header {
  514. background-color: #f5f7fa;
  515. padding: 15rpx 0;
  516. border-bottom: 1rpx solid #e4e7ed;
  517. }
  518. .split-table-row {
  519. padding: 15rpx 0;
  520. border-bottom: 1rpx solid #e4e7ed;
  521. align-items: center;
  522. &:last-child {
  523. border-bottom: none;
  524. }
  525. }
  526. .header-text {
  527. @include font-styles($size: tiny, $weight: regular, $color: tertiary);
  528. text-align: center;
  529. display: block;
  530. }
  531. .table-cell {
  532. display: flex;
  533. align-items: center;
  534. justify-content: center;
  535. padding: 0 10rpx;
  536. box-sizing: border-box;
  537. }
  538. .action-column {
  539. display: flex;
  540. align-items: center;
  541. justify-content: center;
  542. }
  543. /* 自定义下拉框样式 - 隐藏原生箭头 */
  544. .custom-select {
  545. width: 100%;
  546. height: 50rpx;
  547. border-radius: 0;
  548. border: 1rpx solid #e5e7eb;
  549. text-align: center;
  550. /* 增加右侧内边距,为自定义箭头留出空间 */
  551. @include font-styles($size: tiny, $weight: regular, $color: secondary);
  552. background-color: #fff;
  553. /* 确保隐藏所有浏览器的原生箭头 */
  554. appearance: none !important;
  555. -webkit-appearance: none !important;
  556. -moz-appearance: none !important;
  557. -o-appearance: none !important;
  558. cursor: pointer;
  559. /* 使用自定义SVG箭头 */
  560. background-repeat: no-repeat;
  561. background-position: right 8rpx center;
  562. background-size: 12rpx 12rpx;
  563. box-sizing: border-box;
  564. position: relative;
  565. /* 防止箭头在焦点状态下显示 */
  566. &:focus {
  567. outline: none;
  568. border-color: #409eff;
  569. box-shadow: 0 0 0 2rpx rgba(64, 158, 255, 0.2);
  570. }
  571. /* 针对IE/Edge浏览器的特殊处理 */
  572. &::-ms-expand {
  573. display: none !important;
  574. }
  575. /* 针对某些旧版浏览器的额外处理 */
  576. &::-webkit-select-arrow {
  577. display: none !important;
  578. }
  579. /* 添加伪元素覆盖可能残留的箭头 */
  580. &::after {
  581. content: '';
  582. position: absolute;
  583. right: 8rpx;
  584. top: 50%;
  585. transform: translateY(-50%);
  586. width: 12rpx;
  587. height: 12rpx;
  588. background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23909399' d='M6 8l-4-4h8z'/%3E%3C/svg%3E");
  589. background-repeat: no-repeat;
  590. background-size: 100% 100%;
  591. pointer-events: none;
  592. z-index: 1;
  593. }
  594. }
  595. /* 百分比输入框样式 */
  596. .percentage-input {
  597. text-align: center;
  598. background-color: #f9f9f9;
  599. color: #606266;
  600. text-align: center;
  601. padding: 0rpx !important;
  602. }
  603. /* 账户类型标签样式 */
  604. .account-type {
  605. padding: 4rpx 16rpx;
  606. border-radius: 12rpx;
  607. font-size: 24rpx;
  608. font-weight: 500;
  609. color: #fff;
  610. text-align: center;
  611. }
  612. .account-type.frontend {
  613. background-color: #409eff;
  614. }
  615. .account-type.backend {
  616. background-color: #909399;
  617. }
  618. /* 调整表格布局,使其更紧凑 */
  619. .split-table {
  620. width: 100%;
  621. margin-top: 10rpx;
  622. }
  623. .split-table-header,
  624. .split-table-row {
  625. padding: 10rpx 0;
  626. }
  627. .table-cell {
  628. padding: 0 5rpx;
  629. }
  630. /* 调整输入框样式 */
  631. .percentage-input {
  632. width: 80%;
  633. height: 50rpx;
  634. font-size: 28rpx;
  635. }
  636. /* 归属公司单选框样式 */
  637. .radio-wrapper {
  638. cursor: pointer;
  639. display: flex;
  640. align-items: center;
  641. justify-content: center;
  642. }
  643. .radio-circle {
  644. width: 32rpx;
  645. height: 32rpx;
  646. border-radius: 50%;
  647. border: 2rpx solid #dcdfe6;
  648. display: flex;
  649. align-items: center;
  650. justify-content: center;
  651. transition: all 0.3s ease;
  652. }
  653. .radio-circle.active {
  654. border-color: #67c23a;
  655. background-color: #67c23a;
  656. }
  657. /* 确认入库按钮样式 */
  658. .confirm-button-container {
  659. display: flex;
  660. justify-content: center;
  661. align-items: center;
  662. padding: 40rpx 0;
  663. margin-top: 20rpx;
  664. }
  665. /* 响应式布局调整 */
  666. @media screen and (max-width: 750rpx) {
  667. .split-table {
  668. overflow-x: auto;
  669. }
  670. .custom-select {
  671. width: 100%;
  672. }
  673. .account-type {
  674. padding: 2rpx 10rpx;
  675. font-size: 22rpx;
  676. }
  677. }
  678. @media screen and (min-width: 751rpx) {
  679. .table-cell {
  680. padding: 0 10rpx;
  681. }
  682. }
  683. </style>