common_form.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 label="" lebel-width="0px" prop={`venderId`} rules={[diyRequired.bind(this)((rule, value)=>{
  58. if(this.logs){
  59. this.logs.push({errMsg:`*供应商名称不能为空`})
  60. }
  61. this?.tishicuowu?.()
  62. return new Error('必须填写')
  63. })]}>
  64. <el-select
  65. style="width:100%"
  66. value={this.formData.venderId}
  67. onInput={val => {
  68. this.formData.venderId = val
  69. }}
  70. placeholder="请选择"
  71. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  72. onChange={val => {
  73. if (val) {
  74. this.formData['venderName'] = this.gysList.find(item => item.venderId == val).venderName
  75. } else {
  76. this.formData['venderName'] = ''
  77. }
  78. if (!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name)) {
  79. this.formData.goodsPurchaseId = ''
  80. this.cgrkOrder = []
  81. this.formData.items = []
  82. this.getCgrkOrder()
  83. }
  84. }}
  85. >
  86. {this.gysList.map(item => (
  87. <el-option key={item.venderId} label={item.venderName} value={item.venderId}></el-option>
  88. ))}
  89. </el-select>
  90. </el-form-item>
  91. </div>
  92. </el-descriptions-item>
  93. <el-descriptions-item label={(JSON.parse(localStorage.getItem('greemall_user')).joinCode === "NO"?'':'*') + (!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name) ?'出库仓库':'入库仓库')}>
  94. <div class="redbordererr">
  95. <el-form-item label="" lebel-width="0px" prop={`storageId`} rules={JSON.parse(localStorage.getItem('greemall_user')).joinCode === "NO"?[]:[diyRequired.bind(this)((rule, value)=>{
  96. if(this.logs){
  97. this.logs.push({errMsg:`*仓库不能为空`})
  98. }
  99. this?.tishicuowu?.()
  100. return new Error('必须填写')
  101. })]}>
  102. <el-select
  103. style="width:100%"
  104. value={this.formData.storageId}
  105. onInput={val => {
  106. this.formData.storageId = val
  107. }}
  108. placeholder="请选择"
  109. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status) || !!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name)}
  110. onChange={val => {
  111. if (val) {
  112. this.formData['storageName'] = this.warehouseList.find(item => item.storageId == val).storageName
  113. } else {
  114. this.formData['storageName'] = ''
  115. }
  116. }}
  117. >
  118. {this.warehouseList.map(item => (
  119. <el-option key={item.storageId} label={item.storageName} value={item.storageId}></el-option>
  120. ))}
  121. </el-select>
  122. </el-form-item>
  123. </div>
  124. </el-descriptions-item>
  125. {!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name) ? (
  126. <el-descriptions-item label="*采购入库单">
  127. <div class="redbordererr">
  128. <el-form-item label="" lebel-width="0px" prop={`goodsPurchaseId`} rules={[diyRequired.bind(this)((rule, value)=>{
  129. if(this.logs){
  130. this.logs.push({errMsg:`*采购入库单不能为空`})
  131. }
  132. this?.tishicuowu?.()
  133. return new Error('必须填写')
  134. })]}>
  135. <el-select
  136. style="width:100%"
  137. value={this.formData.goodsPurchaseId}
  138. onInput={val => {
  139. this.formData.goodsPurchaseId = val
  140. }}
  141. placeholder="请选择"
  142. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  143. filterable={true}
  144. clearable={true}
  145. onChange={val => {
  146. this.formData.items = []
  147. if (val) {
  148. goodsPurchaseDetail({ id: val, isQuery: true }).then(res => {
  149. this.joinCode = res.data.joinCode === "CODE"
  150. this.formData.storageId = res.data.storageId
  151. this.formData.storageName = res.data.storageName
  152. this.getWarehouseList()
  153. this.formData.items = res.data.items.map(item => ({
  154. brandId: item.brandId,
  155. brandName: item.brandName,
  156. mainId: item.mainId,
  157. mainName: item.mainName,
  158. smallId: item.smallId,
  159. smallName: item.smallName,
  160. goodsMaterialId: item.goodsMaterialId,
  161. goodsMaterialName: item.goodsMaterialName,
  162. specsName: item.specsName,
  163. unit: item.unit,
  164. insideQty: item.insideQty,
  165. outQty: item.outQty,
  166. partsQty: item.partsQty,
  167. qty: item.qty,
  168. price: item.price,
  169. amount: item.amount,
  170. stockQty: item.stockQty,
  171. factoryNo: item.factoryNo,
  172. retQty: '',
  173. retInsideQty: '',
  174. retOutQty: '',
  175. retPartsQty: '',
  176. insideCodeQty: '',
  177. outCodeQty: '',
  178. partsCodeQty: '',
  179. retAmount: '',
  180. details: {}
  181. }))
  182. })
  183. }
  184. }}
  185. >
  186. {this.cgrkOrder.map(item => (
  187. <el-option
  188. key={item.id}
  189. label={`${item.id} | 销售金额:${item.totalAmount || '-'} | 入库时间:${item.examineTime || '-'
  190. }`}
  191. value={item.id}
  192. ></el-option>
  193. ))}
  194. </el-select>
  195. </el-form-item>
  196. </div>
  197. </el-descriptions-item>
  198. ) : (
  199. <el-descriptions-item label=""></el-descriptions-item>
  200. )}
  201. </el-descriptions>
  202. <el-descriptions
  203. border
  204. title=""
  205. column={4}
  206. colon={false}
  207. labelStyle={{ width: '8%' }}
  208. contentStyle={{ width: '17%' }}
  209. style="margin-top:-1px"
  210. >
  211. {!!~['merchandisePurchaseReturn'].indexOf(this?.$route?.name)
  212. ? [
  213. <el-descriptions-item label="退货数量">{this.formData.totalQty}</el-descriptions-item>,
  214. <el-descriptions-item label="退款金额">{this.formData.totalAmount}</el-descriptions-item>,
  215. <el-descriptions-item label=""></el-descriptions-item>,
  216. <el-descriptions-item label=""></el-descriptions-item>
  217. ]
  218. : null}
  219. <el-descriptions-item label="制单人">{this.formData.createBy}</el-descriptions-item>
  220. <el-descriptions-item label="制单时间">{this.formData.createTime}</el-descriptions-item>
  221. <el-descriptions-item label="审核人">{this.formData.examineBy}</el-descriptions-item>
  222. <el-descriptions-item label="审核时间">{this.formData.examineTime}</el-descriptions-item>
  223. </el-descriptions>
  224. <el-descriptions
  225. border
  226. title=""
  227. column={4}
  228. colon={false}
  229. labelStyle={{ width: '8%' }}
  230. contentStyle={{ width: '17%' }}
  231. style="margin-top:-1px"
  232. >
  233. <el-descriptions-item label="备注" contentStyle={{ width: '92%' }}>
  234. <el-input
  235. type="textarea"
  236. placeholder="请输入内容"
  237. value={this.formData.remark}
  238. onInput={val => {
  239. this.formData.remark = val
  240. }}
  241. maxlength="200"
  242. show-word-limit
  243. autosize={{ minRows: 2, maxRows: 4 }}
  244. disabled={!!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  245. ></el-input>
  246. </el-descriptions-item>
  247. </el-descriptions>
  248. <el-descriptions
  249. border
  250. title=""
  251. column={4}
  252. colon={false}
  253. labelStyle={{ width: '8%' }}
  254. contentStyle={{ width: '17%' }}
  255. style="margin-top:-1px"
  256. >
  257. <el-descriptions-item label="附件" contentStyle={{ width: '92%' }}>
  258. <ImageUpload
  259. fileList={this.formData.fileUrl}
  260. uid="imgSrc666_materials_drawing_images"
  261. limit={1}
  262. isEdit={!~['WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)}
  263. fileType={['image']}
  264. />
  265. </el-descriptions-item>
  266. </el-descriptions>
  267. </div>
  268. )
  269. }
  270. }
  271. ]
  272. }
  273. },
  274. methods: {
  275. // 获取供应商列表
  276. getGysList() {
  277. listPageV2({
  278. pageNum: 1,
  279. pageSize: -1,
  280. params: [
  281. { param: 'a.status', compare: '=', value: 'ON' },
  282. { param: 'a.vender_type', compare: 'like', value: '商品' }
  283. ]
  284. }).then(res => {
  285. this.gysList = res.data.records
  286. })
  287. },
  288. getCgrkOrder() {console.log(111)
  289. if (this.formData.venderId) {
  290. goodsPurchaseList({
  291. pageNum: 1,
  292. pageSize: -1,
  293. params: [
  294. { param: 'a.vender_id', compare: '=', value: this.formData.venderId },
  295. { "param": "a.status", "compare": "=", "value": "OK" }
  296. ]
  297. }).then(res => {
  298. this.cgrkOrder = res.data.records
  299. if (this.formData.goodsPurchaseId) {
  300. goodsPurchaseDetail({ id: this.formData.goodsPurchaseId, isQuery: true }).then(res => {
  301. this.joinCode = res.data.joinCode === "CODE"
  302. })
  303. }
  304. })
  305. }
  306. },
  307. getWarehouseList(){
  308. storageListPageV2({
  309. pageNum: 1,
  310. pageSize: -1,
  311. params: [{param: "a.type", compare: "like", value: "商品"}]
  312. }).then(res => {
  313. this.warehouseList = res.data.records
  314. })
  315. }
  316. }
  317. }