index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div class="card-search">
  3. <a-form ref="formRef" name="advanced_search" class="ant-advanced-search-form" :model="searchParams">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="任务名称" :label-col="{span:6}" name="name">
  7. <a-input v-model:value="searchParams.name" placeholder=""/>
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="下达时间" :label-col="{span:6}" name="name">
  12. <a-range-picker format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']" @change="onRangeChange"/>
  13. </a-form-item>
  14. </a-col>
  15. <a-col :span="6">
  16. <a-form-item label="完成时间" :label-col="{span:6}" name="name">
  17. <a-range-picker format="YYYY-MM-DD" :placeholder="['开始日期', '结束日期']" @change="onFinishChange"/>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :span="5" style="text-align: right">
  21. <a-button type="primary" html-type="submit" @click="onSearch">查询</a-button>
  22. </a-col>
  23. </a-row>
  24. <a-row :gutter="24">
  25. <a-col :span="6">
  26. <a-form-item label="所属县区" :label-col="{span:6}" name="regionCode">
  27. <a-select
  28. ref="select"
  29. v-model:value="searchParams.regionCode"
  30. :options="regionList"
  31. :field-names="{ label: 'name', value: 'code' }"
  32. :allow-clear="true"
  33. @change="changeCity"
  34. >
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :span="6">
  39. <a-form-item label="所属街道" :label-col="{span:6}" name="streetCode">
  40. <a-select
  41. ref="select"
  42. v-model:value="searchParams.streetCode"
  43. :options="streetList"
  44. :field-names="{ label: 'name', value: 'code' }"
  45. :allow-clear="true"
  46. @change="loadData"
  47. >
  48. </a-select>
  49. </a-form-item>
  50. </a-col>
  51. <a-col :span="6">
  52. <a-form-item label="任务类型" :label-col="{span:6}" name="workTypeId">
  53. <a-select
  54. ref="select"
  55. v-model:value="searchParams.workTypeId"
  56. :options="taskTypeList"
  57. :field-names="{ label: 'name', value: 'value' }"
  58. :allow-clear="true"
  59. @change="loadData"
  60. >
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. </a-row>
  65. <a-row class="edit-operation">
  66. <a-col :span="24" style="text-align: right">
  67. <a-button type="primary" html-type="submit" @click='onAdd'>新增</a-button>
  68. <!-- <a-button type="primary" html-type="submit" @click='exportPost()'>导出</a-button>-->
  69. <BExportExcel :title="'导出'" :filename="'任务信息'"
  70. :url="'taskAndLog/dotask/export'"
  71. :params="{...searchParams, isExport: true, rows:10000}"></BExportExcel>
  72. </a-col>
  73. </a-row>
  74. </a-form>
  75. <div class="search-result-list">
  76. <a-table :columns="columns" :data-source="dataList" :scroll="{ x:'100%', y: 500 }" :pagination="pagination"
  77. :loading="formState.loading"
  78. @change="handleTableChange"
  79. :row-selection="{ selectedRowKeys: formState.selectedRowKeys, onChange: onSelectChange}"
  80. :row-key="(record)=>record.dotaskID"
  81. bordered>
  82. <template #bodyCell="{ column, text, record }">
  83. <template v-if="column.key === 'operation'">
  84. <div class="table-operation">
  85. <a-button type="link" size="small" @click='onEdit(record)'>编辑</a-button>
  86. <a-button type="link" size="small" @click="onDel(record)">删除</a-button>
  87. </div>
  88. </template>
  89. </template>
  90. </a-table>
  91. </div>
  92. </div>
  93. </template>
  94. <script lang="ts">
  95. import {get} from '@/api/common';
  96. import {reactive, ref, computed, defineComponent,createVNode} from 'vue';
  97. import {DownOutlined, UpOutlined,ExclamationCircleOutlined} from '@ant-design/icons-vue';
  98. import type {FormInstance,SelectProps} from 'ant-design-vue';
  99. import type {TableColumnsType, TableProps} from 'ant-design-vue';
  100. import {getList,del} from '@/api/taskAndLog/dotask';
  101. import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
  102. import {getPaginationTotalTitle} from "@/utils/common";
  103. import {message, Modal} from "ant-design-vue";
  104. import dayjs from 'dayjs';
  105. import {useTabsViewStore} from "@/store/modules/tabsView";
  106. export default defineComponent({
  107. name: 'doTaskList',
  108. components: { DownOutlined, UpOutlined, BExportExcel},
  109. setup() {
  110. const formRef = ref<FormInstance>();
  111. const searchParams = reactive({
  112. pageIndex: 1,
  113. pageSize: 20,
  114. primaryKey: '',
  115. recordStatus:1,
  116. startTime:'',
  117. endTime:'',
  118. finishStartTime:'',
  119. finishEndTime:'',
  120. workTypeId:'',
  121. regionCode:'',
  122. streetCode:''
  123. });
  124. const formState = reactive({
  125. total: 0,
  126. selectedRowKeys: [],
  127. loading: false
  128. });
  129. const columns: TableColumnsType = [
  130. {
  131. title: '序号',
  132. align: "center",
  133. key: 'institutionID',
  134. customRender: item => `${searchParams.pageSize * (searchParams.pageIndex - 1) + item.index + 1}`
  135. },
  136. {title: '任务名称', dataIndex: 'dotaskName', key: 'dotaskName', align: "center"},
  137. {title: '任务类型', dataIndex: 'workTypeName', key: 'workTypeName', width: 120, align: "center"},
  138. {
  139. title: '任务完成时间', dataIndex: 'finishTime', key: 'finishTime', align: "center", customRender: (item) => {
  140. return item.record.finishTime==null?"": (dayjs(item.record.finishTime).format('YYYY-MM-DD'))
  141. }
  142. },
  143. {title: '所属县区', dataIndex: 'regionName', key: 'regionName', align: "center"},
  144. {title: '所属街道', dataIndex: 'streetName', key: 'streetName', align: "center"},
  145. {title: '执行用户数', dataIndex: 'userCount', key: 'userCount', align: "center"},
  146. {title: '下达时间', dataIndex: 'createTime', key: 'createTime', align: "center",customRender:(item)=>{
  147. return item.record.createTime==null?"": (dayjs(item.record.createTime).format('YYYY-MM-DD'))
  148. }},
  149. {title: '下达人', dataIndex: 'createName', key: 'createName', align: "center"},
  150. {title: '操作', key: 'operation', fixed: 'right', width: 170, align: "center"},
  151. ];
  152. const pagination = computed(() => ({
  153. total: formState.total,
  154. current: searchParams.pageIndex,
  155. pageSize: searchParams.pageSize,
  156. showSizeChanger: true,
  157. showTotal: total => getPaginationTotalTitle(total)
  158. }));
  159. const tabsViewStore = useTabsViewStore();
  160. const regionList = ref<SelectProps['options']>();
  161. const streetList = ref<SelectProps['options']>();
  162. const taskTypeList = ref<SelectProps['options']>();
  163. const dataList = ref([]);
  164. const onAdd = () => {
  165. tabsViewStore.addTabByPath('/taskAndLog/dotask/add', null);
  166. };
  167. const onEdit = (item: any) => {
  168. tabsViewStore.addTabByPath('/taskAndLog/dotask/edit', { id: item.dotaskID });
  169. };
  170. get('system/area/getCityList',{}).then(data=>{
  171. console.log(data);
  172. regionList.value=data;
  173. console.log(regionList.value);
  174. });
  175. get('system/dictionary/getDictionaryItemByCodeList',{code:'TaskType'}).then(data=>{
  176. console.log(data);
  177. taskTypeList.value=data;
  178. });
  179. const changeCity=()=>{
  180. if(searchParams.regionCode) {
  181. get('system/area/getAreaList', {code: searchParams.regionCode}).then(data => {
  182. streetList.value = data;
  183. })
  184. }
  185. loadData();
  186. }
  187. const loadData = async function () {
  188. formState.loading = true;
  189. const result: any = await getList(searchParams);
  190. dataList.value = result.list;
  191. console.log(dataList.value);
  192. formState.total = result.total;
  193. formState.loading = false;
  194. }
  195. const handleTableChange: TableProps['onChange'] = (pag: { pageSize: number; current: number },) => {
  196. searchParams.pageIndex = pag.current;
  197. searchParams.pageSize = pag.pageSize;
  198. loadData();
  199. };
  200. const onSelectChange = (selectedRowKeys: any) => {
  201. formState.selectedRowKeys = selectedRowKeys;
  202. };
  203. const onRangeChange=(dateString)=>{
  204. searchParams.startTime = dateString ? dateString[0].format("YYYY-MM-DD") : '';
  205. searchParams.endTime = dateString ? dateString[1].format("YYYY-MM-DD") : '';
  206. loadData();
  207. }
  208. const onFinishChange=(dateString)=>{
  209. searchParams.finishStartTime = dateString ? dateString[0].format("YYYY-MM-DD") : '';
  210. searchParams.finishEndTime = dateString ? dateString[1].format("YYYY-MM-DD") : '';
  211. loadData();
  212. }
  213. const onSearch = () => {
  214. loadData();
  215. }
  216. const onDel = (item: any) => {
  217. if (item) {
  218. formState.selectedRowKeys.push(item.dotaskID as never)
  219. }
  220. if (formState.selectedRowKeys.length <= 0) {
  221. message.warning('请选择需要删除的数据!');
  222. return false;
  223. }
  224. Modal.confirm({
  225. title: '确认删除选中的数据?',
  226. icon: createVNode(ExclamationCircleOutlined),
  227. content: '',
  228. okText: '确认删除',
  229. okType: 'danger',
  230. okButtonProps: {},
  231. cancelText: '取消',
  232. onOk() {
  233. del(formState.selectedRowKeys).then(() => {
  234. loadData();
  235. });
  236. },
  237. onCancel() {
  238. },
  239. });
  240. };
  241. const importPost = () => {
  242. console.log('导入');
  243. }
  244. const exportPost = () => {
  245. console.log('导出');
  246. }
  247. const onOperates = () => {
  248. console.log('新增');
  249. };
  250. return {
  251. changeCity,
  252. regionList,
  253. streetList,
  254. taskTypeList,
  255. formRef,
  256. searchParams,
  257. formState,
  258. columns,
  259. pagination,
  260. dataList,
  261. handleTableChange,
  262. onSelectChange,
  263. onSearch,
  264. onOperates,
  265. importPost,
  266. exportPost,
  267. onDel,
  268. onRangeChange,
  269. onFinishChange,
  270. loadData,
  271. onAdd,
  272. onEdit
  273. };
  274. },
  275. created() {
  276. this.loadData();
  277. },
  278. activated() {
  279. if (history.state.params?.reload)
  280. this.loadData();
  281. }
  282. });
  283. </script>
  284. <style lang="less" scoped></style>