taskForm.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="">
  3. <u-sticky offset-top="50">
  4. <u-subsection fontSize='25' mode='subsection' :list="list" :current="curNow" @change="sectionChange"
  5. activeColor='#157A2C'></u-subsection>
  6. </u-sticky>
  7. <view v-show='curNow===0'>
  8. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='200rpx' :rules="rules">
  9. <u-form-item label="编码" prop="code" borderBottom>
  10. {{ form.code || '-' }}
  11. </u-form-item>
  12. <u-form-item label="名称" prop="name" borderBottom>
  13. {{ form.name || '-' }}
  14. </u-form-item>
  15. <u-form-item label="来源类型" prop="relationTypeName" borderBottom>
  16. {{ form.relationTypeName || '-' }}
  17. </u-form-item>
  18. <u-form-item label="来源编码" prop="relationCode" borderBottom>
  19. {{ form.relationCode || '-' }}
  20. </u-form-item>
  21. <u-form-item label="来源名称" prop="relationName" borderBottom>
  22. {{ form.relationName || '-' }}
  23. </u-form-item>
  24. <u-form-item label="创建人" prop="createUserName" borderBottom>
  25. {{ form.createUserName || '-' }}
  26. </u-form-item>
  27. <u-form-item label="创建时间" prop="createTime" borderBottom>
  28. {{ form.createTime || '-' }}
  29. </u-form-item>
  30. </u--form>
  31. </view>
  32. <view v-show='curNow===1'>
  33. <view v-for="(item, index) in form.detailList" :key="index">
  34. <view class="product-card">
  35. <view class="card-header">
  36. <text class="product-name">{{ item.productName || '物品' + (index + 1) }}</text>
  37. <text class="product-price">{{ item.productCode || '-' }}</text>
  38. </view>
  39. <view class="card-body">
  40. <view class="info-row">
  41. <text class="info-label">异常类型:</text>
  42. <uni-data-select v-model="item.exceptionDetermine" :localdata="exceptionDetermineOptions"></uni-data-select>
  43. </view>
  44. <view class="info-row">
  45. <text class="info-label">处置方式:</text>
  46. <uni-data-select v-model="item.exceptionDispose" :localdata="exceptionDisposeOptions"></uni-data-select>
  47. </view>
  48. <view class="info-row" v-for="(field, idx) in tableField.filter(f => f.field !== 'exceptionDetermine' && f.field !== 'exceptionDispose')" :key="idx">
  49. <text class="info-label">{{ field.label }}:</text>
  50. <text class="info-value">{{ formatValue(item, field) }} {{ field.unit || '' }}</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <u-empty v-if="!list || list.length === 0" text="暂无物品清单" marginTop="100"></u-empty>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. exceptionmanagementInfoAPI
  62. } from '@/api/saleManage/saleorder/index.js'
  63. import fileMain from "@/pages/doc/index.vue"
  64. import commonProductList from "../common/commonProductList.vue"
  65. import { mapGetters } from 'vuex'
  66. import {transactionMethodsOp,shippingModeOp,shippingModePurchaseOp, pricingWayList, levelList, quoteTypeOp, relationTypeOption} from '@/enum/dict.js'
  67. export default {
  68. components: {
  69. fileMain,
  70. commonProductList
  71. },
  72. props: {
  73. businessId: {
  74. default: ''
  75. },
  76. taskDefinitionKey: {
  77. default: ''
  78. },
  79. },
  80. // 暴露方法给父组件调用
  81. expose: ['validateDetailList', 'form'],
  82. computed: {
  83. ...mapGetters(['getDictValue']),
  84. exceptionDetermineOptions() {
  85. return this.form.relationType == 1
  86. ? [
  87. { text: '多发', value: '1' },
  88. { text: '少发', value: '2' },
  89. { text: '错发', value: '3' },
  90. { text: '损坏', value: '4' }
  91. ]
  92. : [
  93. { text: '多收', value: '1' },
  94. { text: '少收', value: '2' },
  95. { text: '错收', value: '3' },
  96. { text: '损坏', value: '4' }
  97. ];
  98. },
  99. tableField() {
  100. return [
  101. // { label: '异常类型', field: 'exceptionDetermine' },
  102. // { label: '处置方式', field: 'exceptionDispose' },
  103. { label: '规格', field: 'specification' },
  104. { label: '型号', field: 'modelType' },
  105. { label: '批次号', field: 'batchNo' },
  106. { label: '发货条码', field: 'barcodes' },
  107. { label: '物料代号', field: 'materielDesignation' },
  108. { label: this.form.relationType == 1 ? '客户代号' : '供应商代号', field: 'clientCode' },
  109. { label: '客户代号', field: 'customerMark' },
  110. { label: '刻码', field: 'engrave' },
  111. { label: '包装规格', field: 'packingSpecification' },
  112. { label: '机型', field: 'modelKey' },
  113. { label: '颜色', field: 'colorKey' },
  114. { label: '异常数量', field: 'totalCount' },
  115. { label: '描述', field: 'describes' },
  116. ]
  117. },
  118. },
  119. data() {
  120. return {
  121. form: {},
  122. list: ['基本信息', '物品清单'],
  123. curNow: 0,
  124. rules: {
  125. // 可添加基础表单校验规则
  126. },
  127. exceptionDisposeOptions: [
  128. { text: '退货入库', value: '1' },
  129. { text: '返工返修', value: '2' },
  130. { text: '报损', value: '3' },
  131. { text: '报废', value: '4' }
  132. ],
  133. }
  134. },
  135. async mounted() {
  136. await this.getDetailData(this.businessId);
  137. },
  138. methods: {
  139. // 格式化字段值
  140. formatValue(item, field) {
  141. let value = item[field.field]
  142. // 数量字段显示单位
  143. if (field.field === 'saleCount') {
  144. const unit = item.saleUnit || ''
  145. return value ? value + (unit ? ' ' + unit : '') : '-'
  146. }
  147. // 计量数量字段显示单位
  148. if (field.field === 'totalCount') {
  149. const unit = item.measuringUnit || ''
  150. return value ? value + (unit ? ' ' + unit : '') : '-'
  151. }
  152. // 单重字段显示单位
  153. if (field.field === 'singleWeight') {
  154. const unit = item.weightUnit || ''
  155. return value ? value + (unit ? ' ' + unit : '') : '-'
  156. }
  157. // 总重字段显示单位
  158. if (field.field === 'totalWeight') {
  159. const unit = item.weightUnit || ''
  160. return value ? value + (unit ? ' ' + unit : '') : '-'
  161. }
  162. // 增重重量字段显示单位
  163. if (field.field === 'increaseTotalWeight') {
  164. const unit = item.weightUnit || ''
  165. return value ? value + (unit ? ' ' + unit : '') : '-'
  166. }
  167. // 计价方式特殊处理
  168. if (field.type === 'pricingWay') {
  169. const found = pricingWayList.find(p => p.id === value)
  170. return found ? found.name : '-'
  171. }
  172. // 收货状态特殊处理
  173. if (field.field === 'isException') {
  174. return value == 1 ? '有异常' : '无异常'
  175. }
  176. if (field.field === 'packingQuantity') {
  177. const unit = item.packingUnit || ''
  178. return value ? value + (unit ? ' ' + unit : '') : '-'
  179. }
  180. if (field.field === 'type') {
  181. return value == 1 ? '已回收' : '未回收'
  182. }
  183. // 字典类型处理
  184. if (field.type === 'dict') {
  185. return this.getDictValue(field.dictName, value) || '-'
  186. }
  187. return value || '-'
  188. },
  189. sectionChange(index) {
  190. this.curNow = index;
  191. },
  192. async getDetailData(id) {
  193. const data = await exceptionmanagementInfoAPI(id);
  194. data.relationTypeName = relationTypeOption[data.relationType] || '-';
  195. // 初始化明细列表的异常类型和处置方式
  196. if (data.detailList && data.detailList.length > 0) {
  197. data.detailList.forEach(item => {
  198. item.exceptionDetermine = item.exceptionDetermine ? String(item.exceptionDetermine) : ''
  199. item.exceptionDispose = item.exceptionDispose ? String(item.exceptionDispose) : ''
  200. })
  201. }
  202. this.form = data;
  203. },
  204. // 校验明细列表
  205. validateDetailList() {
  206. return new Promise((resolve, reject) => {
  207. if (!this.form.detailList || this.form.detailList.length === 0) {
  208. resolve()
  209. return
  210. }
  211. for (let i = 0; i < this.form.detailList.length; i++) {
  212. const item = this.form.detailList[i]
  213. if (!item.exceptionDetermine) {
  214. uni.showToast({ title: `第${i + 1}条物品的异常类型不能为空`, icon: 'none' })
  215. reject(new Error('异常类型不能为空'))
  216. return
  217. }
  218. if (!item.exceptionDispose) {
  219. uni.showToast({ title: `第${i + 1}条物品的处置方式不能为空`, icon: 'none' })
  220. reject(new Error('处置方式不能为空'))
  221. return
  222. }
  223. }
  224. resolve()
  225. })
  226. },
  227. getTableValue() {
  228. return new Promise(async (resolve, reject) => {
  229. try {
  230. await this.validateDetailList()
  231. // await this.$refs.outForm[0].validate()
  232. resolve(this.form)
  233. } catch {
  234. reject(null)
  235. }
  236. })
  237. },
  238. }
  239. }
  240. </script>
  241. <style scoped>
  242. .btnConcel {
  243. margin-top: 20rpx;
  244. }
  245. .product-card {
  246. margin: 20rpx;
  247. padding: 20rpx;
  248. background: #fff;
  249. border-radius: 12rpx;
  250. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  251. }
  252. .card-header {
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. padding-bottom: 16rpx;
  257. border-bottom: 1rpx solid #eee;
  258. margin-bottom: 16rpx;
  259. }
  260. .product-name {
  261. font-size: 28rpx;
  262. font-weight: bold;
  263. color: #333;
  264. }
  265. .product-price {
  266. font-size: 26rpx;
  267. /* color: #157a2c; */
  268. /* font-weight: bold; */
  269. }
  270. .card-body {
  271. display: flex;
  272. flex-wrap: wrap;
  273. }
  274. .info-row {
  275. width: 50%;
  276. display: flex;
  277. padding: 8rpx 0;
  278. box-sizing: border-box;
  279. align-items: center;
  280. padding-right: 10rpx;
  281. }
  282. .info-label {
  283. color: #666;
  284. font-size: 26rpx;
  285. flex-shrink: 0;
  286. }
  287. .info-value {
  288. color: #333;
  289. font-size: 26rpx;
  290. overflow: hidden;
  291. text-overflow: ellipsis;
  292. white-space: nowrap;
  293. }
  294. </style>