SelectCustomerInquiryModal.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <a-modal
  3. title="选择客户询价单(select customer inquiry)"
  4. width="95%"
  5. :visible="visible"
  6. :maskClosable="false"
  7. switchFullscreen
  8. @ok="handleOk"
  9. @cancel="handleCancel"
  10. >
  11. <div>
  12. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px">
  13. <div class="table-page-search-wrapper">
  14. <a-form :model="queryParams" :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="searchQuery">
  15. <a-row :gutter="24">
  16. <a-col :md="6" :sm="8">
  17. <a-form-item label="询价单号(bill code)">
  18. <j-input placeholder="请输入" v-model:value="queryParams.billCode" />
  19. </a-form-item>
  20. </a-col>
  21. <a-col :md="6" :sm="8">
  22. <a-form-item label="单据日期(bill date)">
  23. <a-range-picker value-format="YYYY-MM-DD" v-model:value="billDate" @change="changeBillDate" class="query-group-cust" />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="6" :sm="8">
  27. <a-form-item label="询价项目(inquiry project)">
  28. <ApiSelect
  29. :api="ProjectOption"
  30. showSearch
  31. v-model:value="queryParams.inquiryProject"
  32. optionFilterProp="label"
  33. resultField="records"
  34. labelField="code"
  35. valueField="id"
  36. :disabled="fatherProject !== ''"
  37. :params="{ pageSize: -1 }"
  38. />
  39. </a-form-item>
  40. </a-col>
  41. <template v-if="toggleSearchStatus">
  42. <!-- <a-col :md="6" :sm="8">
  43. <a-form-item label="业务类型(busyness type)">
  44. <JDictSelectTag v-model:value="queryParams.busynessType" placeholder="请选择" dictCode="busyness_type"/>
  45. </a-form-item>
  46. </a-col> -->
  47. <a-col :md="6" :sm="8">
  48. <a-form-item label="优先级(priority)">
  49. <JDictSelectTag v-model:value="queryParams.priority" placeholder="请选择" dictCode="priority" />
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="6" :sm="8">
  53. <a-form-item label="产品分类(product class)">
  54. <ApiSelect
  55. :api="ClassList"
  56. showSearch
  57. v-model:value="queryParams.productionClass"
  58. :filterOption="true"
  59. resultField="records"
  60. labelField="name"
  61. valueField="id"
  62. :params="{ pageSize: -1 }"
  63. optionFilterProp="label"
  64. />
  65. </a-form-item>
  66. </a-col>
  67. <a-col :md="6" :sm="8">
  68. <a-form-item label="机型(model)">
  69. <JDictSelectTag v-model:value="queryParams.model" placeholder="请选择" dictCode="model_typer" />
  70. </a-form-item>
  71. </a-col>
  72. <a-col :md="6" :sm="8">
  73. <a-form-item label="产品编号(product code)">
  74. <j-input placeholder="请输入" v-model:value="queryParams.productCode" />
  75. </a-form-item>
  76. </a-col>
  77. <a-col :md="8" :sm="8">
  78. <a-form-item label="采购询价组(procurement inquiry team)" :label-col="labelCol1" :wrapper-col="wrapperCol1">
  79. <JSelectDept v-model:value="queryParams.inquiryTeam" :multiple="false" />
  80. </a-form-item>
  81. </a-col>
  82. </template>
  83. <a-col :md="6" :sm="8">
  84. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  85. <a-button type="primary" @click="searchQuery">查询(search)</a-button>
  86. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置(reset)</a-button>
  87. <a @click="handleToggleSearch" style="margin-left: 8px">
  88. {{ toggleSearchStatus ? '收起' : '展开' }}
  89. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  90. </a>
  91. </span>
  92. </a-col>
  93. </a-row>
  94. </a-form>
  95. </div>
  96. </a-card>
  97. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px">
  98. <a-alert type="info" show-icon class="alert" style="margin-bottom: 8px">
  99. <template #message>
  100. <template v-if="selectedRowKeys.length > 0">
  101. <span>已选中 {{ selectedRowKeys.length }} 条记录</span>
  102. <a-divider type="vertical" />
  103. <a @click="selectedRowKeys = []">清空</a>
  104. </template>
  105. <template v-else>
  106. <span>未选中任何数据</span>
  107. </template>
  108. </template>
  109. </a-alert>
  110. <a-table
  111. :columns="columns"
  112. :row-key="(record) => record.childId"
  113. :data-source="dataSource"
  114. bordered
  115. size="small"
  116. @change="handleTableChange"
  117. :pagination="pagination"
  118. :scroll="{ x: 4500, y: 400 }"
  119. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  120. />
  121. </a-card>
  122. </div>
  123. </a-modal>
  124. </template>
  125. <script lang="ts" setup>
  126. import { ref, reactive } from 'vue';
  127. import { defHttp } from '/@/utils/http/axios';
  128. import { message } from 'ant-design-vue';
  129. import { filterObj, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
  130. import { JDictSelectTag, ApiSelect, JInput } from '/@/components/Form';
  131. import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
  132. import { ProjectOption, ClassList } from '../purchaseInquiryForm.api';
  133. const emit = defineEmits(['selectCustomerInquiry']); //定义emit
  134. let classOption = ref([]);
  135. var visible = ref(false);
  136. const columns = [
  137. {
  138. type: 'selection',
  139. fixed: 'left',
  140. width: 0,
  141. },
  142. {
  143. title: '询价单号(bill code)',
  144. dataIndex: 'billCode',
  145. key: 'billCode',
  146. align: 'center',
  147. },
  148. {
  149. title: '单据日期(bill date)',
  150. dataIndex: 'billDate',
  151. key: 'billDate',
  152. align: 'center',
  153. },
  154. {
  155. title: '询价项目(inquiry project)',
  156. dataIndex: 'inquiryProject_dictText',
  157. key: 'inquiryProjec',
  158. align: 'center',
  159. width: 200,
  160. },
  161. // {
  162. // title: '询价客户(inquiry customer)',
  163. // key: 'inquiryCustomer',
  164. // dataIndex: 'inquiryCustomer_dictText',
  165. // align:"center",
  166. // ellipsis: true,
  167. // },
  168. {
  169. title: '询价有效期(inquiry period)',
  170. align: 'center',
  171. dataIndex: 'time',
  172. width: 250,
  173. customRender: ({ text, record }) => {
  174. if (record.inquiryPeriodBegin && record.inquiryPeriodEnd) {
  175. text = record.inquiryPeriodBegin + '~' + record.inquiryPeriodEnd;
  176. } else if (!record.inquiryPeriodBegin) {
  177. text = record.inquiryPeriodEnd;
  178. } else if (!record.inquiryPeriodEnd) {
  179. text = record.inquiryPeriodBegin;
  180. } else {
  181. text = '';
  182. }
  183. return text;
  184. },
  185. },
  186. {
  187. title: '优先级(priority)',
  188. align: 'center',
  189. dataIndex: 'priority_dictText',
  190. },
  191. {
  192. title: '产品分类(production class)',
  193. align: 'center',
  194. dataIndex: 'productClass',
  195. },
  196. {
  197. title: '机型(headModel)',
  198. align: 'center',
  199. dataIndex: 'headModel',
  200. },
  201. {
  202. title: '采购询价组(procurenment inquiry team)',
  203. key: 'inquiryTeam',
  204. dataIndex: 'inquiryTeam_dictText',
  205. align: 'center',
  206. },
  207. {
  208. title: '产品编码(product code)',
  209. key: 'productCode',
  210. dataIndex: 'productCode',
  211. align: 'center',
  212. },
  213. {
  214. title: '产品英文名(product english name)',
  215. key: 'englishName',
  216. dataIndex: 'englishName',
  217. align: 'center',
  218. ellipsis: true,
  219. width: 250,
  220. },
  221. {
  222. title: '型号(child model)',
  223. key: 'childModel',
  224. dataIndex: 'childModel',
  225. align: 'center',
  226. width: 250,
  227. },
  228. {
  229. title: '厂家(factory)',
  230. key: 'factory',
  231. dataIndex: 'factory',
  232. align: 'center',
  233. width: 250,
  234. },
  235. {
  236. title: '质量等级(quality grade)',
  237. key: 'qualityGrade',
  238. dataIndex: 'qualityGrade',
  239. align: 'center',
  240. width: 250,
  241. },
  242. {
  243. title: '数量(quantity)',
  244. key: 'quantity',
  245. dataIndex: 'quantity',
  246. align: 'center',
  247. width: 250,
  248. },
  249. {
  250. title: '单位(unit)',
  251. key: 'unit',
  252. dataIndex: 'unit',
  253. align: 'center',
  254. width: 250,
  255. },
  256. {
  257. title: '备注(notes)',
  258. key: 'notes',
  259. dataIndex: 'notes',
  260. align: 'center',
  261. width: 250,
  262. },
  263. ];
  264. const labelCol = ref({
  265. xs: { span: 24 },
  266. sm: { span: 9 },
  267. });
  268. const wrapperCol = ref({
  269. xs: { span: 24 },
  270. sm: { span: 15 },
  271. });
  272. const labelCol1 = ref({
  273. xs: { span: 24 },
  274. sm: { span: 11 },
  275. });
  276. const wrapperCol1 = ref({
  277. xs: { span: 24 },
  278. sm: { span: 13 },
  279. });
  280. const dataSource = ref([]);
  281. let selectedRowKeys = ref([]);
  282. let selectedRows = ref([]);
  283. var fatherProject = ref('');
  284. var fatherSourceCode = ref('');
  285. const toggleSearchStatus = ref(false);
  286. var billDate = ref([]);
  287. const queryParams = ref({
  288. billCode: '',
  289. inquiryProject: '',
  290. busynessType: '',
  291. priority: '',
  292. productionClass: '',
  293. model: '',
  294. productCode: '',
  295. inquiryTeam: '',
  296. projectName: '',
  297. billDate_begin: '',
  298. billDate_end: '',
  299. });
  300. let pagination = ref({
  301. current: 1,
  302. pageSize: 10,
  303. total: '', // 假设总共有100条数据
  304. showSizeChanger: true,
  305. showQuickJumper: true,
  306. showTotal: (total, range) => {
  307. return range[0] + '-' + range[1] + ' 共' + total + '条';
  308. },
  309. size: 'small',
  310. });
  311. function loadData() {
  312. let params = getQueryParams();
  313. defHttp
  314. .get({ url: '/saleCode/saleInquiryForm/alertSaleInquiryList', params }, { isTransformResponse: false })
  315. .then((res) => {
  316. if (res.success) {
  317. dataSource.value = res.result.records;
  318. pagination.value.total = res.result.total;
  319. pagination.value.current = res.result.current;
  320. pagination.value.pageSize = res.result.size;
  321. } else {
  322. message.error(res.message);
  323. }
  324. })
  325. .finally(() => {
  326. // loading.value = false;
  327. });
  328. }
  329. function getQueryParams() {
  330. let params = Object.assign(queryParams.value);
  331. params.pageNo = pagination.value.current;
  332. params.pageSize = pagination.value.pageSize;
  333. if (fatherProject.value && fatherProject.value !== '') {
  334. params.inquiryProject = fatherProject.value;
  335. } else {
  336. params.inquiryProject = params.inquiryProject;
  337. }
  338. return filterObj(params);
  339. }
  340. function handleTableChange(paginations, filters, sorter) {
  341. pagination.value.total = paginations.total;
  342. pagination.value.current = paginations.current;
  343. pagination.value.pageSize = paginations.pageSize;
  344. loadData();
  345. }
  346. function getOptiom() {
  347. defHttp
  348. .get({ url: 'baseCode/baseProductClass/list' }, { isTransformResponse: false })
  349. .then((res) => {
  350. if (res.success) {
  351. classOption.value = [];
  352. res.result.records.forEach((element) => {
  353. var obj = {
  354. label: element.name ? element.name : '无名称请维护',
  355. value: element.id ? element.id : '',
  356. };
  357. classOption.value.push(obj);
  358. });
  359. }
  360. })
  361. .finally(() => {
  362. // loading.value = false;
  363. });
  364. }
  365. function searchQuery() {
  366. pagination.value.current = 1;
  367. loadData();
  368. }
  369. function searchReset() {
  370. billDate.value = [];
  371. queryParams.value = {
  372. billCode: '',
  373. inquiryProject: '',
  374. busynessType: '',
  375. priority: '',
  376. productionClass: '',
  377. model: '',
  378. productCode: '',
  379. inquiryTeam: '',
  380. projectName: '',
  381. billDate_begin: '',
  382. billDate_end: '',
  383. };
  384. pagination.value.current = 1;
  385. pagination.value.pageSize = 10;
  386. loadData();
  387. }
  388. function handleToggleSearch() {
  389. toggleSearchStatus.value = !toggleSearchStatus.value;
  390. }
  391. function onSelectChange(keys, rows) {
  392. selectedRowKeys.value = keys;
  393. selectedRows.value = rows;
  394. }
  395. function handleOk() {
  396. var arr = [];
  397. selectedRows.value.map((item) => arr.push(item.billCode));
  398. if (fatherSourceCode.value && fatherSourceCode.value !== '') {
  399. arr.push(fatherSourceCode.value);
  400. }
  401. if (selectedRowKeys.value.length == 0) {
  402. message.error('请勾选数据');
  403. } else if (new Set(arr).size !== 1) {
  404. message.error('请勾选询价单号相同的数据');
  405. } else {
  406. emit('selectCustomerInquiry', selectedRows.value);
  407. handleCancel();
  408. }
  409. }
  410. function handleCancel() {
  411. visible.value = false;
  412. billDate.value = [];
  413. queryParams.value = {
  414. billCode: '',
  415. inquiryProject: '',
  416. busynessType: '',
  417. priority: '',
  418. productionClass: '',
  419. model: '',
  420. productCode: '',
  421. inquiryTeam: '',
  422. projectName: '',
  423. billDate_begin: '',
  424. billDate_end: '',
  425. };
  426. selectedRowKeys.value = [];
  427. selectedRows.value = [];
  428. pagination.value.current = 1;
  429. pagination.value.pageSize = 10;
  430. }
  431. function getTable(formData) {
  432. visible.value = true;
  433. if (formData.projectName && formData.projectName !== '') {
  434. fatherProject.value = formData.inquiryProject;
  435. } else {
  436. fatherProject.value = '';
  437. }
  438. if (formData.sourceCode && formData.sourceCode !== '') {
  439. fatherSourceCode.value = formData.sourceCode;
  440. } else {
  441. fatherSourceCode.value = '';
  442. }
  443. loadData();
  444. getOptiom();
  445. }
  446. function changeBillDate(prop) {
  447. if (prop) {
  448. billDate.value = prop;
  449. queryParams.value.billDate_begin = prop[0];
  450. queryParams.value.billDate_end = prop[1];
  451. } else {
  452. billDate.value = [];
  453. queryParams.value.billDate_begin = '';
  454. queryParams.value.billDate_end = '';
  455. }
  456. }
  457. defineExpose({
  458. getTable,
  459. });
  460. </script>
  461. <style scoped lang="less">
  462. /deep/.ant-form-item {
  463. margin-bottom: 8px !important;
  464. }
  465. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  466. // padding: 8px !important;
  467. // }
  468. </style>