taskForm.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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='140rpx'>
  9. <!-- @tap="showDeptPicker" -->
  10. <u-form-item label="需求类型" prop="sourceTypeName" borderBottom>
  11. <u--input style="width: 100%;" disabled v-model="form.sourceTypeName"></u--input>
  12. </u-form-item>
  13. <!-- @tap="showUserPicker" -->
  14. <u-form-item label="需求单名称" prop="requirementName" borderBottom>
  15. <u--input style="width: 100%;" disabled v-model="form.requirementName"></u--input>
  16. <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
  17. </u-form-item>
  18. <u-form-item label="需求部门" prop="requireDeptName" borderBottom>
  19. <u--input style="width: 100%;" disabled v-model="form.requireDeptName"></u--input>
  20. </u-form-item>
  21. <u-form-item label="需求人" prop="requireUserName" borderBottom>
  22. <u--input style="width: 100%;" disabled v-model="form.requireUserName"></u--input>
  23. </u-form-item>
  24. <u-form-item v-if='form.sourceType==1' label="销售合同" prop="saleContractName" borderBottom>
  25. <u--input style="width: 100%;" disabled v-model="form.saleContractName"></u--input>
  26. </u-form-item>
  27. <u-form-item v-if='form.sourceType==1' label="销售订单" prop="saleOrderNo" borderBottom>
  28. <u--input style="width: 100%;" disabled v-model="form.saleOrderNo"></u--input>
  29. </u-form-item>
  30. <u-form-item label="是否接受拆单" prop="acceptUnpack" borderBottom>
  31. <u-tag v-if='form.acceptUnpack==1' text="接受" size="large" type="success"></u-tag>
  32. <u-tag v-else-if='form.acceptUnpack==0' text="不接受" size="large" type="warning"></u-tag>
  33. <u--input v-else style="width: 100%;" disabled v-model="form.acceptUnpack"></u--input>
  34. </u-form-item>
  35. <u-form-item label="用途" prop="useTo" borderBottom>
  36. <u--input style="width: 100%;" disabled v-model="form.useTo"></u--input>
  37. </u-form-item>
  38. <u-form-item label="附件" prop="fileId" borderBottom>
  39. <fileMain type="view" v-model="form.fileId"></fileMain>
  40. </u-form-item>
  41. <u-form-item label="备注" prop="remark" borderBottom>
  42. <u--input style="width: 100%;" disabled v-model="form.remark"></u--input>
  43. </u-form-item>
  44. </u--form>
  45. </view>
  46. <view v-show='curNow==1'>
  47. <view v-for="(item,index) in form['detailList']" :key="index">
  48. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" ref="uForm" labelWidth='140rpx'>
  49. <u-row v-for="(key,index1) in tableField" :key="index1">
  50. <u-col :span="12">
  51. <u-form-item :label="key.label" prop="categoryName" borderBottom>
  52. <view v-if="key.field == 'expectReceiveDate'">
  53. <view v-if="item.arrivalWay == 2" style="color: #42b983;" @click="settingDate(item, index)">
  54. 分批时间
  55. </view>
  56. <u--input v-else style="width: 100%;" :title='item[key.field]' disabled
  57. v-model="item[key.field]"></u--input>
  58. </view>
  59. <view v-else-if="key.field == 'technicalDrawings' || key.field == 'files'">
  60. <fileMain type="view" v-model="item[key.field]"></fileMain>
  61. </view>
  62. <u--input v-else style="width: 100%;" :title='item[key.field]' disabled
  63. v-model="item[key.field]"></u--input>
  64. </u-form-item>
  65. </u-col>
  66. </u-row>
  67. </u--form>
  68. <u-gap height="40" bgColor="#f0f0f0"></u-gap>
  69. </view>
  70. </view>
  71. <timePopup ref="timePopupRef" :isView="true"></timePopup>
  72. </view>
  73. </template>
  74. <script>
  75. import {
  76. getPurchaseRequirementByIdsAPI
  77. } from '@/api/wt/index.js'
  78. import fileMain from "@/pages/doc/index.vue"
  79. import { levelList, lbjtList } from '@/enum/dict'
  80. import { getByCode } from '@/api/pda/common.js'
  81. import timePopup from '@/pages/purchasingManage/components/timePopup.vue'
  82. export default {
  83. props: {
  84. businessId: {
  85. default: ''
  86. },
  87. taskDefinitionKey: {
  88. default: ''
  89. },
  90. },
  91. components: {
  92. fileMain,
  93. timePopup
  94. },
  95. data() {
  96. return {
  97. detailData: {},
  98. form: {},
  99. tableField: [{
  100. label: '名称',
  101. field: 'productName',
  102. },
  103. {
  104. label: '编码',
  105. field: 'productCode',
  106. },
  107. {
  108. label: '分类',
  109. field: 'productCategoryName',
  110. },
  111. {
  112. label: '数量',
  113. field: 'purchaseCountName',
  114. },
  115. // {
  116. // label: '单位',
  117. // field: 'purchaseUnit',
  118. // },
  119. {
  120. label: '计量数量',
  121. field: 'totalCountName',
  122. },
  123. // {
  124. // label: '计量单位',
  125. // field: 'measuringUnit',
  126. // },
  127. {
  128. label: '包装规格',
  129. field: 'packingSpecification',
  130. },
  131. {
  132. label: '物品级别',
  133. field: 'goodsLevelName',
  134. },
  135. {
  136. label: '库存数量',
  137. field: 'availableCountBase',
  138. },
  139. {
  140. label: '已采数量',
  141. field: 'doneTotalCount', // measuringUnit
  142. },
  143. {
  144. label: '待采数量',
  145. field: 'waitTotalCount', // measuringUnit
  146. },
  147. {
  148. label: '工序',
  149. field: 'taskName',
  150. },
  151. {
  152. label: '批次号',
  153. field: 'batchNo',
  154. },
  155. {
  156. label: '供应商',
  157. field: 'supplierName',
  158. },
  159. {
  160. label: '产地',
  161. field: 'provenanceName',
  162. },
  163. {
  164. label: '型号',
  165. field: 'modelType',
  166. },
  167. {
  168. label: '规格',
  169. field: 'specification',
  170. },
  171. {
  172. label: '品牌',
  173. field: 'brand',
  174. },
  175. {
  176. label: '机型',
  177. field: 'modelKey',
  178. },
  179. {
  180. label: '颜色',
  181. field: 'colorKey',
  182. },
  183. {
  184. label: '到货方式',
  185. field: 'arrivalWayName',
  186. },
  187. {
  188. label: '到货日期',
  189. field: 'expectReceiveDate',
  190. },
  191. {
  192. label: '属性类型',
  193. field: 'produceTypeName',
  194. },
  195. {
  196. label: '图纸附件',
  197. field: 'technicalDrawings',
  198. },
  199. {
  200. label: '附件',
  201. field: 'files',
  202. },
  203. {
  204. label: '备注',
  205. field: 'remark',
  206. },
  207. ],
  208. list: ['基本信息', '需求清单'],
  209. curNow: 0,
  210. arrivalWayList: [
  211. { text: '一次性到货', value: 1 },
  212. { text: '分批到货', value: 2 }
  213. ],
  214. purchase_origin: [],
  215. current: {},
  216. currentIndex: -1,
  217. }
  218. },
  219. async mounted() {
  220. this.getByCode()
  221. await this.getDetailData(this.businessId);
  222. },
  223. methods: {
  224. sectionChange(index) {
  225. this.curNow = index;
  226. },
  227. settingDate(item, index) {
  228. console.log(item, index)
  229. this.current = item;
  230. this.currentIndex = index;
  231. this.$refs.timePopupRef.open(item, index)
  232. },
  233. async getDetailData(id) {
  234. const data = await getPurchaseRequirementByIdsAPI(id);
  235. this.form = data
  236. this.form.fileId = this.form.fileId ? JSON.parse(this.form.fileId) : [];
  237. this.form.detailList.forEach(item => {
  238. item.purchaseCountName = (item.purchaseCount ? item.purchaseCount : '') + item.purchaseUnit;
  239. item.totalCountName = (item.totalCount ? item.totalCount : '') + item.measuringUnit;
  240. item.goodsLevelName = levelList.find(i => i.value == item.goodsLevel)?.text || '';
  241. item.doneTotalCount = (item.doneTotalCount ? item.doneTotalCount : '') + item.measuringUnit;
  242. item.waitTotalCount = (item.waitTotalCount ? item.waitTotalCount : '') + item.measuringUnit;
  243. item.arrivalWayName = this.arrivalWayList.find(i => i.value == item.arrivalWay)?.text || '';
  244. item.produceTypeName = item.produceType ? item.produceType.map(i => lbjtList[i]).join(',') : '';
  245. item.provenanceName = this.getProvenance(item.provenance);
  246. })
  247. console.log('form~~~', this.form)
  248. },
  249. getProvenance(item) {
  250. if (!item) {
  251. return '';
  252. }
  253. let arr = item;
  254. if(!Array.isArray(arr)) {
  255. console.log('arr is not array, convert to array')
  256. arr = arr.split(',');
  257. }
  258. return arr && arr.length ? arr.map((i) => {
  259. return this.purchase_origin.find(p => p.value == i)?.text
  260. }).join(',') : '';
  261. },
  262. getByCode() {
  263. const codeS = ['purchase_origin']
  264. codeS.forEach(async (code) => {
  265. const codeValue = await getByCode(code);
  266. this[code] = codeValue.map(item => {
  267. const key = Object.keys(item)[0]
  268. return {
  269. value: key,
  270. text: item[key]
  271. }
  272. })
  273. console.log(code, this[code])
  274. })
  275. },
  276. }
  277. }
  278. </script>
  279. <style>
  280. </style>