SelectSaleOrderMianModal.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <a-modal
  3. title="选择销售订单(Select Sale Order)"
  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="订单编号(bill 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 label="单据日期(bill date)">
  22. <a-range-picker value-format="YYYY-MM-DD" v-model:value="billDate" @change="changeBillDate" class="query-group-cust"/>
  23. </a-form-item>
  24. </a-col>
  25. <template v-if="toggleSearchStatus">
  26. <a-col :md="6" :sm="8">
  27. <a-form-item label="项目(project)">
  28. <ApiSelect
  29. :api="projectListList"
  30. showSearch
  31. v-model:value="queryParams.project"
  32. optionFilterProp="label"
  33. resultField="records"
  34. labelField="name"
  35. valueField="id"
  36. />
  37. </a-form-item>
  38. </a-col>
  39. </template>
  40. <a-col :md="6" :sm="8">
  41. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  42. <a-button type="primary" @click="searchQuery" >查询(search)</a-button>
  43. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置(reset)</a-button>
  44. <a @click="handleToggleSearch" style="margin-left: 8px">
  45. {{ toggleSearchStatus ? '收起' : '展开' }}
  46. <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
  47. </a>
  48. </span>
  49. </a-col>
  50. </a-row>
  51. </a-form>
  52. </div>
  53. </a-card>
  54. <a-card :body-style="{ padding: '10px' }" :bordered="false" style="margin: 10px;">
  55. <a-alert type="info" show-icon class="alert" style="margin-bottom: 8px">
  56. <template #message>
  57. <template v-if="selectedRowKeys.length > 0">
  58. <span>已选中 {{ selectedRowKeys.length }} 条记录</span>
  59. <a-divider type="vertical" />
  60. <a @click="selectedRowKeys = []">清空</a>
  61. </template>
  62. <template v-else>
  63. <span>未选中任何数据</span>
  64. </template>
  65. </template>
  66. </a-alert>
  67. <a-table
  68. :columns="columns"
  69. :row-key="record => record.id"
  70. :data-source="dataSource"
  71. bordered
  72. size="small"
  73. @change="handleTableChange"
  74. :pagination="pagination"
  75. :scroll="{ x: 1500, y: 300 }"
  76. :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
  77. >
  78. </a-table>
  79. </a-card>
  80. </div>
  81. </a-modal>
  82. </template>
  83. <script lang="ts" setup>
  84. import {ref, reactive } from 'vue';
  85. import { defHttp} from '/@/utils/http/axios';
  86. import { message } from 'ant-design-vue';
  87. import { filterObj, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
  88. import { ApiSelect, JInput} from '/@/components/Form/index';
  89. const emit = defineEmits([ 'selectSaleOrderMian']); //定义emit
  90. var visible = ref(false)
  91. const columns = [
  92. {
  93. type: 'selection',
  94. fixed: 'left',
  95. width:0
  96. },
  97. {
  98. title: '订单编号(bill code)',
  99. dataIndex: 'billCode',
  100. key: 'billCode',
  101. align:"center",
  102. width:250,
  103. },
  104. {
  105. title: '单据日期(bill date)',
  106. dataIndex: 'billDate',
  107. key: 'billDate',
  108. align:"center"
  109. },
  110. {
  111. title: '项目(project)',
  112. dataIndex: 'projectName',
  113. key: 'projectName',
  114. align:"center",
  115. width:250,
  116. ellipsis: true,
  117. },
  118. {
  119. title: '客户(customer)',
  120. dataIndex: 'customerName',
  121. key: 'supplierName',
  122. align:"center",
  123. ellipsis: true,
  124. },
  125. {
  126. title: '订单金额(order money)',
  127. key: 'orderMoney',
  128. dataIndex: 'orderMoney',
  129. align:"center",
  130. width:250,
  131. },
  132. ];
  133. const labelCol = ref({
  134. xs: { span: 24 },
  135. sm: { span: 9 },
  136. });
  137. const wrapperCol = ref({
  138. xs: { span: 24 },
  139. sm: { span: 15 },
  140. });
  141. const dataSource =ref([]);
  142. let selectedRowKeys = ref([]);
  143. let selectedRows = ref([]);
  144. const toggleSearchStatus = ref(false);
  145. var billDate = ref([])
  146. const queryParams = ref({
  147. billCode:'',
  148. project:'',
  149. projectName:'',
  150. billDate_begin:'',
  151. billDate_end:'',
  152. submit:'1',
  153. close:'0'
  154. });
  155. let pagination = ref({
  156. current: 1,
  157. pageSize: 10,
  158. total: '', // 假设总共有100条数据
  159. showSizeChanger: true,
  160. showQuickJumper: true,
  161. showTotal: (total, range) => {
  162. return range[0] + "-" + range[1] + " 共" + total + "条"
  163. },
  164. size:'small'
  165. });
  166. function loadData(){
  167. let params = getQueryParams();
  168. defHttp.get({ url: '/saleCode/saleOrder/list',params}, { isTransformResponse: false })
  169. .then((res) => {
  170. if (res.success) {
  171. dataSource.value = res.result.records;
  172. pagination.value.total = res.result.total;
  173. pagination.value.current = res.result.current;
  174. pagination.value.pageSize = res.result.size;
  175. } else {
  176. message.error(res.message);
  177. }
  178. })
  179. .finally(() => {
  180. // loading.value = false;
  181. });
  182. }
  183. function getQueryParams(){
  184. let params = Object.assign(queryParams.value);
  185. params.pageNo = pagination.value.current;
  186. params.pageSize = pagination.value.pageSize;
  187. return filterObj(params);
  188. }
  189. function handleTableChange(paginations, filters, sorter){
  190. pagination.value.total = paginations.total;
  191. pagination.value.current = paginations.current;
  192. pagination.value.pageSize = paginations.pageSize;
  193. loadData()
  194. };
  195. function searchQuery(){
  196. pagination.value.current =1;
  197. loadData();
  198. }
  199. function searchReset(){
  200. billDate.value = []
  201. queryParams.value = {
  202. billCode:'',
  203. project:'',
  204. projectName:'',
  205. billDate_begin:'',
  206. billDate_end:'',
  207. submit:'1',
  208. close:'0'
  209. }
  210. pagination.value.current =1;
  211. pagination.value.pageSize = 10;
  212. loadData();
  213. }
  214. function handleToggleSearch(){
  215. toggleSearchStatus.value = !toggleSearchStatus.value;
  216. }
  217. function onSelectChange(keys,rows){
  218. selectedRowKeys.value = keys
  219. selectedRows.value = rows
  220. }
  221. function handleOk(){
  222. if(selectedRows.value.length!==1){
  223. message.warning('请选择一条数据')
  224. }else{
  225. emit('selectSaleOrderMian', selectedRows.value)
  226. handleCancel()
  227. }
  228. }
  229. function handleCancel(){
  230. visible.value = false
  231. selectedRowKeys.value = []
  232. selectedRows.value=[]
  233. billDate.value = []
  234. queryParams.value = {
  235. billCode:'',
  236. project:'',
  237. projectName:'',
  238. billDate_begin:'',
  239. billDate_end:'',
  240. submit:'1',
  241. close:'0'
  242. }
  243. pagination.value.current =1;
  244. pagination.value.pageSize = 10;
  245. }
  246. function getTable(){
  247. visible.value = true
  248. loadData()
  249. }
  250. function changeBillDate(prop){
  251. if(prop){
  252. billDate.value = prop
  253. queryParams.value.billDate_begin = prop[0]
  254. queryParams.value.billDate_end = prop[1]
  255. }else{
  256. billDate.value = []
  257. queryParams.value.billDate_begin = ''
  258. queryParams.value.billDate_end = ''
  259. }
  260. }
  261. function projectListList(){
  262. let params = {pageSize:-1}
  263. return defHttp.get({url:'/baseCode/baseProjectArchive/list',params});
  264. }
  265. defineExpose({
  266. getTable,
  267. });
  268. </script>
  269. <style scoped lang="less">
  270. /deep/.ant-form-item{
  271. margin-bottom: 8px !important;
  272. }
  273. // /deep/.ant-table-wrapper .ant-table-thead > tr > th, .ant-table-wrapper .ant-table-thead > tr > td{
  274. // padding: 8px !important;
  275. // }
  276. </style>