common_form.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. import { required, diyRequired } from '@/components/template/rules_verify.js'
  2. import { listPageV2 } from '@/api/auxiliaryFittings/supplier'
  3. import { goodsPurchaseList, goodsPurchaseDetail } from '@/api/goodsPurchasedStored.js'
  4. import { storageListPageV2 } from '@/api/storage.js'
  5. import ImageUpload from '@/components/file-upload'
  6. export default {
  7. data() {
  8. return {
  9. gysList: [],
  10. warehouseList: [],
  11. cgrkOrder: []
  12. }
  13. },
  14. computed: {
  15. formItems() {
  16. return [
  17. {
  18. md: 24,
  19. isShow: true,
  20. name: 'slot-component',
  21. formItemAttributes: {
  22. label: '',
  23. prop: '',
  24. 'label-width': '0px'
  25. },
  26. render: (h, { props, onInput }) => {
  27. var { value } = props
  28. return (
  29. <div>
  30. <el-descriptions
  31. border
  32. title=""
  33. column={4}
  34. colon={false}
  35. labelStyle={{ width: '8%' }}
  36. contentStyle={{ width: '17%' }}
  37. >
  38. <el-descriptions-item label="单据状态">
  39. {{ SAVE: '保存', WAIT: '待审核', OK: '通过', FAIL: '失败' }[this.formData.status] || ''}
  40. </el-descriptions-item>
  41. <el-descriptions-item label="单据编号">{this.formData.id || ''}</el-descriptions-item>
  42. <el-descriptions-item label="所属商户" contentStyle={{ width: '42%' }}>
  43. {JSON.parse(localStorage.getItem('greemall_user')).companyName}
  44. </el-descriptions-item>
  45. </el-descriptions>
  46. <el-descriptions
  47. border
  48. title=""
  49. column={3}
  50. colon={false}
  51. labelStyle={{ width: '8%' }}
  52. contentStyle={{ width: '25%' }}
  53. style="margin-top:-1px"
  54. >
  55. <el-descriptions-item label="*供应商名称">
  56. <div class="redbordererr">
  57. <el-form-item
  58. label=""
  59. lebel-width="0px"
  60. prop={`venderId`}
  61. rules={[
  62. diyRequired.bind(this)((rule, value) => {
  63. if (this.logs) {
  64. this.logs.push({ errMsg: `*供应商名称不能为空` })
  65. }
  66. this?.tishicuowu?.()
  67. return new Error('必须填写')
  68. })
  69. ]}
  70. >
  71. <el-select
  72. style="width:100%"
  73. value={this.formData.venderId}
  74. onInput={val => {
  75. this.formData.venderId = val
  76. }}
  77. placeholder="请选择"
  78. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  79. onChange={val => {
  80. if (val) {
  81. this.formData['venderName'] = this.gysList.find(item => item.venderId == val).venderName
  82. } else {
  83. this.formData['venderName'] = ''
  84. }
  85. if (!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name)) {
  86. this.formData.goodsPurchaseId = ''
  87. this.cgrkOrder = []
  88. this.formData.items = []
  89. this.getCgrkOrder()
  90. }
  91. this.formData.planItems = []
  92. }}
  93. >
  94. {this.gysList.map(item => (
  95. <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>
  96. ))}
  97. </el-select>
  98. </el-form-item>
  99. </div>
  100. </el-descriptions-item>
  101. <el-descriptions-item
  102. label={
  103. (JSON.parse(localStorage.getItem('greemall_user')).joinCode === 'NO' ? '' : '*') +
  104. (!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name) ? '出库仓库' : '入库仓库')
  105. }
  106. >
  107. <div class="redbordererr">
  108. <el-form-item label="" lebel-width="0px" prop={`storageId`}>
  109. <el-select
  110. style="width:100%"
  111. value={this.formData.storageId}
  112. onInput={val => {
  113. this.formData.storageId = val
  114. }}
  115. placeholder="请选择"
  116. disabled={
  117. !!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status) ||
  118. !!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name) ||
  119. JSON.parse(localStorage.getItem('greemall_user')).joinCode === 'NO'
  120. }
  121. onChange={val => {
  122. if (val) {
  123. this.formData['storageName'] = this.warehouseList.find(
  124. item => item.storageId == val
  125. ).storageName
  126. } else {
  127. this.formData['storageName'] = ''
  128. }
  129. }}
  130. >
  131. {this.warehouseList.map(item => (
  132. <el-option key={item.storageId} label={item.storageName} value={item.storageId}></el-option>
  133. ))}
  134. </el-select>
  135. </el-form-item>
  136. </div>
  137. </el-descriptions-item>
  138. {!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name) ? (
  139. <el-descriptions-item label="*采购入库单">
  140. <div class="redbordererr">
  141. <el-form-item
  142. label=""
  143. lebel-width="0px"
  144. prop={`goodsPurchaseId`}
  145. rules={[
  146. diyRequired.bind(this)((rule, value) => {
  147. if (this.logs) {
  148. this.logs.push({ errMsg: `*采购入库单不能为空` })
  149. }
  150. this?.tishicuowu?.()
  151. return new Error('必须填写')
  152. })
  153. ]}
  154. >
  155. <el-select
  156. style="width:100%"
  157. value={this.formData.goodsPurchaseId}
  158. onInput={val => {
  159. this.formData.goodsPurchaseId = val
  160. }}
  161. placeholder="请选择"
  162. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  163. filterable={true}
  164. clearable={true}
  165. onChange={val => {
  166. this.formData.items = []
  167. if (val) {
  168. goodsPurchaseDetail({ id: val, isQuery: true }).then(res => {
  169. this.joinCode = res.data.joinCode === 'CODE'
  170. this.formData.storageId = res.data.storageId
  171. this.formData.storageName = res.data.storageName
  172. this.formData.isPlan = res.data.isPlan
  173. this.getWarehouseList(1)
  174. this.formData.items = res.data.items.map(item => ({
  175. brandId: item.brandId,
  176. brandName: item.brandName,
  177. mainId: item.mainId,
  178. mainName: item.mainName,
  179. smallId: item.smallId,
  180. smallName: item.smallName,
  181. goodsMaterialId: item.goodsMaterialId,
  182. goodsMaterialName: item.goodsMaterialName,
  183. specsName: item.specsName,
  184. unit: item.unit,
  185. insideQty: item.insideQty,
  186. outQty: item.outQty,
  187. partsQty: item.partsQty,
  188. qty: item.qty,
  189. price: item.price,
  190. amount: item.amount,
  191. stockQty: item.stockQty,
  192. factoryNo: item.factoryNo,
  193. retQty: '',
  194. retInsideQty: '',
  195. retOutQty: '',
  196. retPartsQty: '',
  197. insideCodeQty: '',
  198. outCodeQty: '',
  199. partsCodeQty: '',
  200. retAmount: '',
  201. details: {}
  202. }))
  203. this.formData.planItems = res.data.planItems
  204. })
  205. }
  206. }}
  207. >
  208. {this.cgrkOrder.map(item => (
  209. <el-option
  210. key={item.id}
  211. label={`${item.id} | 销售金额:${item.totalAmount || '-'} | 入库时间:${
  212. item.examineTime || '-'
  213. }`}
  214. value={item.id}
  215. ></el-option>
  216. ))}
  217. </el-select>
  218. </el-form-item>
  219. </div>
  220. </el-descriptions-item>
  221. ) : !!~['goodsPurchasedStored'].indexOf(this?.$route?.name) ? (
  222. <el-descriptions-item label="*是否关联计划单">
  223. <el-radio
  224. value={this.formData.isPlan}
  225. onInput={v => {
  226. this.formData.isPlan = v
  227. }}
  228. label={true}
  229. >
  230. </el-radio>
  231. <el-radio
  232. value={this.formData.isPlan}
  233. onInput={v => {
  234. this.formData.isPlan = v
  235. }}
  236. label={false}
  237. >
  238. </el-radio>
  239. </el-descriptions-item>
  240. ) : (
  241. <el-descriptions-item label=""></el-descriptions-item>
  242. )}
  243. </el-descriptions>
  244. <el-descriptions
  245. border
  246. title=""
  247. column={4}
  248. colon={false}
  249. labelStyle={{ width: '8%' }}
  250. contentStyle={{ width: '17%' }}
  251. style="margin-top:-1px"
  252. >
  253. {!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name)
  254. ? [
  255. <el-descriptions-item label="退货数量">{this.formData.totalQty}</el-descriptions-item>,
  256. <el-descriptions-item label="退款金额">{this.formData.totalAmount}</el-descriptions-item>,
  257. <el-descriptions-item label=""></el-descriptions-item>,
  258. <el-descriptions-item label=""></el-descriptions-item>
  259. ]
  260. : null}
  261. <el-descriptions-item label="制单人">{this.formData.createBy}</el-descriptions-item>
  262. <el-descriptions-item label="制单时间">{this.formData.createTime}</el-descriptions-item>
  263. <el-descriptions-item label="审核人">{this.formData.examineBy}</el-descriptions-item>
  264. <el-descriptions-item label="审核时间">{this.formData.examineTime}</el-descriptions-item>
  265. </el-descriptions>
  266. <el-descriptions
  267. border
  268. title=""
  269. column={4}
  270. colon={false}
  271. labelStyle={{ width: '8%' }}
  272. contentStyle={{ width: '17%' }}
  273. style="margin-top:-1px"
  274. >
  275. <el-descriptions-item label="*备注" contentStyle={{ width: '92%' }}>
  276. <el-input
  277. type="textarea"
  278. placeholder="请输入内容"
  279. value={this.formData.remark}
  280. onInput={val => {
  281. this.formData.remark = val
  282. }}
  283. maxlength="200"
  284. show-word-limit
  285. autosize={{ minRows: 2, maxRows: 4 }}
  286. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  287. ></el-input>
  288. </el-descriptions-item>
  289. </el-descriptions>
  290. <el-descriptions
  291. border
  292. title=""
  293. column={4}
  294. colon={false}
  295. labelStyle={{ width: '8%' }}
  296. contentStyle={{ width: '17%' }}
  297. style="margin-top:-1px"
  298. >
  299. <el-descriptions-item label="附件" contentStyle={{ width: '92%' }}>
  300. <ImageUpload
  301. fileList={this.formData.fileUrl}
  302. uid="imgSrc666_materials_drawing_images"
  303. limit={1}
  304. isEdit={!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  305. fileType={['image']}
  306. />
  307. </el-descriptions-item>
  308. </el-descriptions>
  309. </div>
  310. )
  311. }
  312. }
  313. ]
  314. }
  315. },
  316. methods: {
  317. // 获取供应商列表
  318. getGysList() {
  319. listPageV2({
  320. pageNum: 1,
  321. pageSize: -1,
  322. params: [
  323. { param: 'a.status', compare: '=', value: 'ON' },
  324. { param: 'a.vender_type', compare: 'like', value: '商品' }
  325. ]
  326. }).then(res => {
  327. this.gysList = res.data.records
  328. })
  329. },
  330. getCgrkOrder() {
  331. if (this.formData.venderId) {
  332. goodsPurchaseList({
  333. pageNum: 1,
  334. pageSize: -1,
  335. params: [
  336. { param: 'a.vender_id', compare: '=', value: this.formData.venderId },
  337. { param: 'a.status', compare: '=', value: 'OK' }
  338. ]
  339. }).then(res => {
  340. this.cgrkOrder = res.data.records
  341. if (this.formData.goodsPurchaseId) {
  342. goodsPurchaseDetail({ id: this.formData.goodsPurchaseId, isQuery: true }).then(res => {
  343. this.joinCode = res.data.joinCode === 'CODE'
  344. })
  345. }
  346. })
  347. }
  348. },
  349. getWarehouseList(type) {
  350. storageListPageV2({
  351. pageNum: 1,
  352. pageSize: -1,
  353. params: [
  354. { param: 'a.type', compare: 'like', value: '商品' },
  355. { param: 'a.status', compare: '=', value: 'true' }
  356. ]
  357. }).then(res => {
  358. if (JSON.parse(localStorage.getItem('greemall_user')).joinCode != 'NO' && !this.formData.storageId && type) {
  359. this.formData.storageId = res.data.records[0].storageId
  360. this.formData.storageName = res.data.records[0].storageName
  361. }
  362. this.warehouseList = res.data.records
  363. })
  364. }
  365. }
  366. }