SelectContractModal.vue 18 KB

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