common_form.js 14 KB

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