SelectQuotationFormForm.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <a-spin :spinning="loading">
  3. <JFormContainer :disabled="disabled">
  4. <template #detail>
  5. <a-form v-bind="formItemLayout" name="SelectQuotationFormForm" ref="formRef">
  6. <a-row>
  7. <a-col :span="12">
  8. <a-form-item label="选定单号(bill code)" v-bind="validateInfos.billCode" id="SelectQuotationFormForm-billCode" name="billCode">
  9. <a-input v-model:value="formData.billCode" placeholder="自动生成" disabled></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :span="12">
  13. <a-form-item label="单据日期(bill date)" v-bind="validateInfos.billDate" id="SelectQuotationFormForm-billDate" name="billDate">
  14. <a-date-picker placeholder="请选择单据日期(bill date)" v-model:value="formData.billDate" value-format="YYYY-MM-DD" style="width: 100%" allow-clear />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :span="12">
  18. <a-form-item label="询价项目(inquiry project)" v-bind="validateInfos.projectName" id="SelectQuotationFormForm-projectName" name="projectName">
  19. <a-input-search v-model:value="formData.projectName" placeholder="请输入询价项目(inquiry project)" allow-clear enter-button="Search" @search="onSearchProject"></a-input-search>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="12">
  23. <a-form-item label="优先级(priority)" v-bind="validateInfos.priority" id="SelectQuotationFormForm-priority" name="priority">
  24. <JDictSelectTag v-model:value="formData.priority" placeholder="请选择" dictCode="priority" disabled/>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="12">
  28. <a-form-item label="产品分类(production class)" v-bind="validateInfos.productionClass" id="SelectQuotationFormForm-productionClass" name="productionClass">
  29. <ApiSelect
  30. :api="ClassList"
  31. showSearch
  32. v-model:value="formData.productionClass"
  33. :filterOption="false"
  34. resultField="records"
  35. labelField="name"
  36. valueField="id"
  37. :params='{pageSize:-1}'
  38. disabled
  39. />
  40. </a-form-item>
  41. </a-col>
  42. <a-col :span="12">
  43. <a-form-item label="机型(model)" v-bind="validateInfos.model" id="SelectQuotationFormForm-model" name="model">
  44. <JDictSelectTag v-model:value="formData.model" placeholder="请选择" dictCode="model_typer" disabled/>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="12">
  48. <a-form-item label="厂家(maker)" v-bind="validateInfos.maker" id="SelectQuotationFormForm-maker" name="maker">
  49. <a-input v-model:value="formData.maker" placeholder="请输入厂家(maker)" allow-clear disabled></a-input>
  50. </a-form-item>
  51. </a-col>
  52. <a-col :span="12">
  53. <a-form-item label="选定备注(selection notes)" v-bind="validateInfos.selectionNotes" id="SelectQuotationFormForm-selectionNotes" name="selectionNotes">
  54. <a-input v-model:value="formData.selectionNotes" placeholder="请输入选定备注备注(selection notes)" allow-clear AutoComplete="off"></a-input>
  55. </a-form-item>
  56. </a-col>
  57. <a-col :span="12">
  58. <a-form-item label="附件(attachs)" v-bind="validateInfos.attachs" id="SelectQuotationFormForm-attachs" name="attachs">
  59. <JUpload v-model:value="formData.attachs"></JUpload>
  60. </a-form-item>
  61. </a-col>
  62. </a-row>
  63. </a-form>
  64. </template>
  65. </JFormContainer>
  66. <!-- 子表单区域 -->
  67. <a-tabs v-model:activeKey="activeKey" animated style=" padding: 24px;padding-top: 0px;">
  68. <a-tab-pane tab="采购报价单选定 - 产品明细(product details)" key="SelectQuotationFormProduct" :forceRender="true">
  69. <j-vxe-table
  70. :keep-source="true"
  71. resizable
  72. ref="SelectQuotationFormProductTableRef"
  73. :loading="SelectQuotationFormProductTable.loading"
  74. :columns="SelectQuotationFormProductTable.columns"
  75. :dataSource="SelectQuotationFormProductTable.dataSource"
  76. :height="340"
  77. :disabled="disabled"
  78. :rowNumber="true"
  79. :rowSelection="true"
  80. asyncRemove
  81. >
  82. <template #selectionSupplier="props">
  83. <a-select v-model:value="props.row.selectionSupplier" style="width: 100%;" @change="selectSupplier(props)" allowClear>
  84. <a-select-option v-for="item in supplierList" :key="item.value" >{{ item.label }}</a-select-option>
  85. </a-select>
  86. </template>
  87. <template #action="props">
  88. <a-popconfirm title="确定删除吗?" @confirm="handleDelete1(props)">
  89. <a>删除(delete)</a>
  90. </a-popconfirm>
  91. </template>
  92. </j-vxe-table>
  93. </a-tab-pane>
  94. <a-tab-pane tab="采购报价单选定 - 船明细(ship details)" key="SelectQuotationFormShip" :forceRender="true">
  95. <j-vxe-table
  96. :keep-source="true"
  97. resizable
  98. ref="SelectQuotationFormShipTableRef"
  99. :loading="SelectQuotationFormShipTable.loading"
  100. :columns="SelectQuotationFormShipTable.columns"
  101. :dataSource="SelectQuotationFormShipTable.dataSource"
  102. :height="340"
  103. :disabled="disabled"
  104. :rowNumber="true"
  105. :rowSelection="true"
  106. >
  107. <template #action="props" >
  108. <a @click="viewAccessory(props)" >查看配件信息(view accessory information)</a>
  109. </template>
  110. </j-vxe-table>
  111. </a-tab-pane>
  112. <a-tab-pane tab="采购报价单选定 - 供应商报价明细(supplier quotation details)" key="SupplierQuotationDetails" :forceRender="true">
  113. <j-vxe-table
  114. :keep-source="true"
  115. resizable
  116. ref="SupplierQuotationDetailsTableRef"
  117. :loading="SupplierQuotationDetailsTable.loading"
  118. :columns="SupplierQuotationDetailsTable.columns"
  119. :dataSource="SupplierQuotationDetailsTable.dataSource"
  120. :rowKey="record => record.childId"
  121. :height="340"
  122. :disabled="disabled"
  123. :rowNumber="true"
  124. :rowSelection="true"
  125. asyncRemove
  126. >
  127. </j-vxe-table>
  128. </a-tab-pane>
  129. <a-tab-pane tab="采购报价单选定 - 供应商汇总金额(supplier summary amount)" key="SupplierSummaryAmount" :forceRender="true">
  130. <j-vxe-table
  131. :keep-source="true"
  132. resizable
  133. ref="SupplierSummaryAmountTableRef"
  134. :loading="SupplierSummaryAmountTable.loading"
  135. :columns="SupplierSummaryAmountTable.columns"
  136. :dataSource="SupplierSummaryAmountTable.dataSource"
  137. :height="340"
  138. :disabled="disabled"
  139. :rowNumber="true"
  140. :rowSelection="true"
  141. asyncRemove
  142. >
  143. </j-vxe-table>
  144. </a-tab-pane>
  145. </a-tabs>
  146. <BaseShipArchiveAccessoriesModal ref="BaseShipArchiveAccessoriesListRef"></BaseShipArchiveAccessoriesModal>
  147. <SelectProjectModal ref="SelectProjectModalRef" @selectProject="addProject"></SelectProjectModal>
  148. </a-spin>
  149. </template>
  150. <script lang="ts">
  151. import { defineComponent, ref, reactive, computed, toRaw, onMounted } from 'vue';
  152. import { defHttp } from '/@/utils/http/axios';
  153. import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
  154. import { SelectQuotationFormShippTable, SelectQuotationFormProductListByMainId, queryDataById, saveOrUpdate,ClassList } from '../SelectionQuotationForm.api';
  155. import { JVxeTable } from '/@/components/jeecg/JVxeTable';
  156. import {SelectQuotationFormShipTableCloumn, SelectQuotationFormProductColumns,SupplierQuotationColumns,SupplierSummaryAmountColumns} from '../SelectionQuotationForm.data';
  157. import BaseShipArchiveAccessoriesModal from '../../../publicComponents/BaseShipArchiveAccessoriesModal.vue';
  158. import SelectProjectModal from '../../../publicComponents/SelectProjectModal.vue';
  159. import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
  160. import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
  161. import { JDictSelectTag,ApiSelect} from '/@/components/Form';
  162. import JSelectInput from '/@/components/Form/src/jeecg/components/JSelectInput.vue';
  163. import { Form ,message} from 'ant-design-vue';
  164. import moment from 'moment';
  165. const useForm = Form.useForm;
  166. export default defineComponent({
  167. name: "SelectQuotationFormForm",
  168. components:{
  169. JVxeTable,
  170. JFormContainer,
  171. BaseShipArchiveAccessoriesModal,
  172. JUpload,
  173. SelectProjectModal,
  174. JDictSelectTag,
  175. JSelectInput,
  176. ApiSelect
  177. },
  178. props:{
  179. formDisabled:{
  180. type: Boolean,
  181. default: false
  182. },
  183. formData: { type: Object, default: ()=>{} },
  184. formBpm: { type: Boolean, default: true }
  185. },
  186. emits:['success'],
  187. setup(props, {emit}) {
  188. const loading = ref(false);
  189. const formRef = ref();
  190. var SelectProjectModalRef = ref()
  191. const SelectQuotationFormShipTableRef = ref();
  192. const SelectQuotationFormShipTable = reactive<Record<string, any>>({
  193. loading: false,
  194. columns: SelectQuotationFormShipTableCloumn,
  195. dataSource: []
  196. });
  197. const SelectQuotationFormProductTableRef = ref();
  198. const SupplierQuotationDetailsTableRef = ref();
  199. const SupplierSummaryAmountTableRef = ref();
  200. const SelectQuotationFormProductTable = reactive<Record<string, any>>({
  201. loading: false,
  202. columns: SelectQuotationFormProductColumns,
  203. dataSource: []
  204. });
  205. const SupplierQuotationDetailsTable = reactive<Record<string, any>>({
  206. loading: false,
  207. columns: SupplierQuotationColumns,
  208. dataSource: []
  209. });
  210. const SupplierSummaryAmountTable = reactive<Record<string, any>>({
  211. loading: false,
  212. columns: SupplierSummaryAmountColumns,
  213. dataSource: []
  214. });
  215. var BaseShipArchiveAccessoriesListRef = ref();
  216. var supplierList = ref([]);
  217. const activeKey = ref('SelectQuotationFormProduct');
  218. const formData = reactive<Record<string, any>>({
  219. id: '',
  220. status: undefined,
  221. delFlag: undefined,
  222. submit: '',
  223. billDate: moment(new Date()).format('YYYY-MM-DD'),
  224. billCode: '',
  225. inquiryProject: '',
  226. projectName:'',
  227. priority: '',
  228. productionClass: '',
  229. model: '',
  230. maker: '',
  231. selectionNotes:'',
  232. attachs:'',
  233. sourceId:''
  234. });
  235. //表单验证
  236. const validatorRules = reactive({
  237. });
  238. const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: false});
  239. const dbData = {};
  240. const formItemLayout = {
  241. labelCol: {xs: {span: 24}, sm: {span: 5}},
  242. wrapperCol: {xs: {span: 24}, sm: {span: 16}},
  243. };
  244. // 表单禁用
  245. const disabled = computed(()=>{
  246. if(props.formBpm === true){
  247. if(props.formData.disabled === false){
  248. return false;
  249. }else{
  250. return true;
  251. }
  252. }
  253. return props.formDisabled;
  254. });
  255. function add() {
  256. resetFields();
  257. SelectQuotationFormShipTable.dataSource = [];
  258. SelectQuotationFormProductTable.dataSource = [];
  259. SupplierQuotationDetailsTable.dataSource = []
  260. SupplierSummaryAmountTable.dataSource = []
  261. activeKey.value = 'SelectQuotationFormProduct'
  262. }
  263. async function edit(row) {
  264. //主表数据
  265. await queryMainData(row.id);
  266. //子表数据
  267. const SelectQuotationFormShipDataList = await SelectQuotationFormShippTable(row['id']);
  268. SelectQuotationFormShipTable.dataSource = [...SelectQuotationFormShipDataList];
  269. const SelectQuotationFormProductDataList = await SelectQuotationFormProductListByMainId(row['id']);
  270. SelectQuotationFormProductTable.dataSource = [...SelectQuotationFormProductDataList];
  271. getSupplierQuotationDetail(formData.inquiryProject)
  272. getSupplierSummaryAmount(formData.inquiryProject)
  273. }
  274. async function queryMainData(id) {
  275. const row = await queryDataById(id);
  276. resetFields();
  277. const tmpData = {};
  278. Object.keys(formData).forEach((key) => {
  279. if(row.hasOwnProperty(key)){
  280. tmpData[key] = row[key]
  281. }
  282. })
  283. //赋值
  284. Object.assign(formData,tmpData);
  285. }
  286. const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, {
  287. 'purQuotationSelectionShip': SelectQuotationFormShipTableRef,
  288. 'purQuotationSelectionProduct': SelectQuotationFormProductTableRef,
  289. });
  290. async function getFormData() {
  291. try {
  292. // 触发表单验证
  293. await validate();
  294. } catch ({ errorFields }) {
  295. if (errorFields) {
  296. const firstField = errorFields[0];
  297. if (firstField) {
  298. formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
  299. }
  300. }
  301. return Promise.reject(errorFields);
  302. }
  303. return transformData(toRaw(formData))
  304. }
  305. async function submitForm() {
  306. const mainData = await getFormData();
  307. const subData = await getSubFormAndTableData();
  308. const values = Object.assign({}, dbData, mainData, subData);
  309. const isUpdate = values.id ? true : false
  310. await saveOrUpdate(values, isUpdate);
  311. //关闭弹窗
  312. emit('success');
  313. }
  314. function setFieldsValue(values) {
  315. if(values){
  316. Object.keys(values).map(k=>{
  317. formData[k] = values[k];
  318. });
  319. }
  320. }
  321. /**
  322. * 值改变事件触发-树控件回调
  323. * @param key
  324. * @param value
  325. */
  326. function handleFormChange(key, value) {
  327. formData[key] = value;
  328. }
  329. async function handleDelete1(prop) {
  330. var newArray = [...SelectQuotationFormProductTable.dataSource]
  331. newArray.splice(prop.rowIndex, 1)
  332. SelectQuotationFormProductTable.dataSource = newArray
  333. }
  334. async function addProject(data) {
  335. if(data.length!==0){
  336. formData.inquiryProject = data[0].id
  337. formData.projectName = data[0].code
  338. await getShipDetail(data[0].id)
  339. await getSupplierQuotationDetail(data[0].id)
  340. await getSupplierSummaryAmount(data[0].id)
  341. }else{
  342. formData.inquiryProject = ''
  343. formData.projectName = ''
  344. }
  345. }
  346. async function getShipDetail(id){
  347. let params = {projectId:id}
  348. await defHttp.get({url:'/purCode/purInquiryForm/getPurInquiryFormByProject',params}, { isTransformResponse: false }).then(res=>{
  349. if(res!==''){
  350. formData.priority = res.priority
  351. formData.productionClass = res.productionClass
  352. formData.model = res.model
  353. formData.maker = res.maker
  354. SelectQuotationFormShipTable.dataSource = res.purInquiryFormShipList
  355. res.purInquiryFormProductList.map(item=>{
  356. item.sourceCode= item.headCode
  357. item.sourceId= item.id
  358. })
  359. formData.sourceId = res.purInquiryFormProductList[0].headCodes
  360. SelectQuotationFormProductTable.dataSource = res.purInquiryFormProductList
  361. }else if(res==''){
  362. message.warning('当前项目还没有报价')
  363. }
  364. })
  365. }
  366. async function getSupplierQuotationDetail(id){
  367. let params = {quotationProject:id}
  368. await defHttp.get({url:'/purCode/purPurchaseQuotation/supplierQuotationDetails',params}, { isTransformResponse: false }).then(res=>{
  369. if(res){
  370. SupplierQuotationDetailsTable.dataSource=res.result.records
  371. supplierList.value= []
  372. res.result.records.map(item=>{
  373. supplierList.value.push({label:item.suppilerName,value:item.quotationSuppiler})
  374. })
  375. supplierList.value = supplierList.value.filter((item, index, self) => {
  376. return index === self.findIndex(obj => obj.value === item.value && obj.label === item.label);
  377. });
  378. }
  379. })
  380. }
  381. function getSupplierSummaryAmount(id){
  382. let params = {quotationProject:id}
  383. defHttp.get({url:'/purCode/purPurchaseQuotation/supplierQuotationTotal',params}, { isTransformResponse: false }).then(res=>{
  384. if(res){
  385. SupplierSummaryAmountTable.dataSource=res.result.records
  386. }
  387. })
  388. }
  389. function viewAccessory(prop){
  390. BaseShipArchiveAccessoriesListRef.value.getTable(prop.row)
  391. }
  392. function onSearchProject(){
  393. SelectProjectModalRef.value.getTable()
  394. }
  395. function selectSupplier(prop){
  396. SupplierQuotationDetailsTable.dataSource.map(item=>{
  397. if(item.productCode==prop.row.productCode&&item.quotationSuppiler==prop.row.selectionSupplier){
  398. var arr = [...SelectQuotationFormProductTable.dataSource]
  399. arr.map((event,index)=>{
  400. if(prop.rowIndex==index){
  401. if(prop.rowIndex==index){
  402. item.sourceCode=event.sourceCode
  403. item.sourceId=event.sourceId
  404. item.sourceId2=item.id
  405. arr[index]={...item}
  406. arr[index].selectionSupplier=item.quotationSuppiler
  407. arr[index].deliveryTime=item.childDeliveryTime
  408. }
  409. }
  410. })
  411. SelectQuotationFormProductTable.dataSource = [...arr]
  412. }
  413. })
  414. }
  415. return {
  416. SelectQuotationFormShipTableRef,
  417. SelectQuotationFormShipTable,
  418. SelectQuotationFormProductTableRef,
  419. SelectQuotationFormProductTable,
  420. validatorRules,
  421. validateInfos,
  422. activeKey,
  423. loading,
  424. formData,
  425. setFieldsValue,
  426. handleFormChange,
  427. formItemLayout,
  428. disabled,
  429. getFormData,
  430. submitForm,
  431. add,
  432. edit,
  433. formRef,
  434. BaseShipArchiveAccessoriesListRef,
  435. viewAccessory,
  436. handleDelete1,
  437. SelectProjectModalRef,
  438. onSearchProject,
  439. addProject,
  440. SupplierQuotationDetailsTableRef,
  441. SupplierQuotationDetailsTable,
  442. SupplierSummaryAmountTableRef,
  443. SupplierSummaryAmountTable,
  444. supplierList,
  445. selectSupplier,
  446. ClassList
  447. }
  448. }
  449. });
  450. </script>
  451. <style lang="less" scoped>
  452. /** 时间和数字输入框样式 */
  453. :deep(.ant-input-number) {
  454. width: 100%;
  455. }
  456. :deep(.ant-calendar-picker) {
  457. width: 100%;
  458. }
  459. /deep/.vxe-table--body-wrapper{
  460. height: 100% !important;
  461. }
  462. /deep/.ant-modal-body{
  463. padding: 24px !important;
  464. }
  465. /deep/.ant-form-item{
  466. margin-bottom: 8px !important;
  467. }
  468. </style>