index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="card-search">
  3. <a-form
  4. ref="formRef"
  5. name="advanced_search"
  6. class="ant-advanced-search-form"
  7. :model="formState"
  8. @finish="onFinish"
  9. >
  10. <a-row :gutter="24">
  11. <a-col :span="6">
  12. <a-form-item
  13. name="practiceBaseName"
  14. label="单位名称"
  15. :label-col="{span:6}">
  16. <!-- <a-input v-model:value="formState.practiceBaseName" style="width: 200px"></a-input>-->
  17. <transfer @ok="transferOk" :default-value="selectKeys" :dictionary-code="'queryType'" :fieldId="'test'"></transfer>
  18. </a-form-item>
  19. </a-col>
  20. <a-col :span="6">
  21. <a-form-item
  22. name="name"
  23. label="岗位名称"
  24. :label-col="{span:6}">
  25. <a-input v-model:value="formState.name" style="width: 200px"></a-input>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :span="6">
  29. <a-form-item
  30. name="schoolYearID"
  31. label="学年"
  32. :label-col="{span:6}">
  33. <a-select v-model:value="formState.schoolYearID"
  34. style="width: 200px" :allowClear="true" ref="select"
  35. :options="schoolYearList">
  36. </a-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :span="6" style="text-align: left">
  40. <a-button type="primary" html-type="submit" @click="onFinish">查询</a-button>
  41. <a-button style="margin: 0 8px" @click="() => {formRef.resetFields();loadData()}">重置</a-button>
  42. <a style="font-size: 12px" @click="expand = !expand">
  43. <template v-if="expand">
  44. <UpOutlined/>
  45. </template>
  46. <template v-else>
  47. <DownOutlined/>
  48. </template>
  49. 展开
  50. </a>
  51. </a-col>
  52. <a-col v-show="expand" :span="6">
  53. <a-form-item
  54. name="majorGradeID"
  55. label="年级专业"
  56. :label-col="{span:6}">
  57. <a-select v-model:value="formState.majorGradeID" show-search :filter-option="filterOption"
  58. style="width: 200px" :allowClear="true"
  59. :options="majorGradeList"
  60. @change="loadData">
  61. </a-select>
  62. </a-form-item>
  63. </a-col>
  64. <a-col v-show="expand" :span="6">
  65. <a-form-item
  66. name="practiceBaseTypeID"
  67. label="基地类型"
  68. :label-col="{span:6}">
  69. <a-select v-model:value="formState.practiceBaseTypeID"
  70. style="width: 200px" :allowClear="true"
  71. :options="practiceBaseTypeList"
  72. @change="loadData">
  73. </a-select>
  74. </a-form-item>
  75. </a-col>
  76. </a-row>
  77. <a-row class="edit-operation">
  78. <a-col :span="24" style="text-align: right">
  79. <a-button type="primary" html-type="button" @click="add" functioncode="T010601">新增</a-button>
  80. <BImportExcel :options="importOptions" @success="loadData" functioncode="T010602"></BImportExcel>
  81. <BExportExcel :title="'导出'" :filename="'岗位信息'" :url="'position/getList'"
  82. :params="{...formState, isExport: true,rows:100000,positionIdList:selectedRowKeys.join(',')}"></BExportExcel>
  83. <a-popconfirm placement="leftTop"
  84. title="是否删除数据?"
  85. @confirm="onDelete()">
  86. <a-button type="primary" style="margin: 0 8px" html-type="button" functioncode="T010604">删除</a-button>
  87. </a-popconfirm>
  88. </a-col>
  89. </a-row>
  90. </a-form>
  91. <div class="search-result-list">
  92. <a-table :columns="columns" :data-source="data" :scroll="{ x:'100%', y: 500 }" :pagination="pagination"
  93. :loading="loading"
  94. :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  95. @change="handleTableChange" :row-key="record=>record.positionID"
  96. bordered>
  97. <template #bodyCell="{ column,record }">
  98. <template v-if="column.key === 'operation'">
  99. <a-button type="link" size="small" @click="detail(record.positionID)">查看
  100. </a-button>
  101. <a-button type="link" size="small" @click="edit(record.positionID)" functioncode="T010603">编辑
  102. </a-button>
  103. </template>
  104. </template>
  105. </a-table>
  106. </div>
  107. </div>
  108. </template>
  109. <script lang="ts">
  110. import {reactive, ref, defineComponent, computed} from 'vue';
  111. import type {FormInstance} from 'ant-design-vue';
  112. import type {TableColumnsType, TableProps,SelectProps} from 'ant-design-vue';
  113. import { get, postdel} from '@/api/common';
  114. import {useRoute, useRouter} from "vue-router";
  115. import {useTabsViewStore} from "@/store/modules/tabsView";
  116. import {getDictionaryItemList} from "@/api/system/dictionary";
  117. import {message} from "ant-design-vue";
  118. import {DownOutlined, UpOutlined} from "@ant-design/icons-vue";
  119. import type {ImportProps} from "@/components/basic/excel/importExcel/ImportProps";
  120. import BImportExcel from "@/components/basic/excel/importExcel/importExcel.vue";
  121. import BExportExcel from "@/components/basic/excel/exportExcel/exportExcel.vue";
  122. import {getPaginationTotalTitle} from "@/utils/common";
  123. import Transfer from '@/components/basic/transfer/Transfer.vue'
  124. export default defineComponent({
  125. name: 'positionlist',
  126. components: {DownOutlined, UpOutlined,BImportExcel,BExportExcel,Transfer},
  127. setup() {
  128. const route = useRoute();
  129. const router = useRouter();
  130. const expand = ref(false);
  131. const formRef = ref<FormInstance>();
  132. const tabsViewStore = useTabsViewStore();
  133. const selectedRowKeys =ref([]) ;
  134. const formState = reactive({
  135. page: 1, rows: 10, schoolYearID: '', majorGradeID: '', practiceBaseTypeID: null,
  136. name: null, practiceBaseName: null, positionID: "", total: 0,isPostManage:true
  137. });
  138. const practiceBaseTypeList = ref([]);
  139. const schoolYearList = ref<SelectProps['options']>();
  140. const majorGradeList = ref<SelectProps['options']>();
  141. const columns: TableColumnsType = [
  142. {
  143. title: '序号',
  144. width: 60,
  145. dataIndex: 'index',
  146. key: 'index',
  147. align: "center",
  148. customRender: item => `${formState.rows * (formState.page - 1) + item.index + 1}`
  149. },
  150. {title: '实习学年', width: 120, dataIndex: 'schoolYear', key: 'schoolYear',align:"center"},
  151. {title: '年级专业', dataIndex: 'majorGradeName', key: '1', width:180},
  152. {title: '基地类型', dataIndex: 'practiceBaseTypeName', key: '2', width: 150, align: "center"},
  153. {title: '单位名称', dataIndex: 'practiceBaseName', key: '3', width: 200},
  154. {title: '岗位名称', dataIndex: 'name', key: '5', width: 120},
  155. {title: '岗位数量', dataIndex: 'qty', key: '5', width: 100,align:"center"},
  156. {title: '备注', dataIndex: 'remark', key: '5', width: 180,ellipsis: true},
  157. {
  158. title: '操作', key: 'operation', width: 120, align: "center"
  159. },
  160. ];
  161. const selectKeys = ref("1,2,3,4");
  162. const transferOk = (keys: string, fieldId: string) => {
  163. selectKeys.value = keys;
  164. console.log(selectKeys.value, fieldId);
  165. }
  166. const importOptions = ref<ImportProps>({
  167. title: "导入",
  168. url: 'position/importData',
  169. columns: [
  170. {cnName: "实习开始年份", enName: "startYear",width:100},
  171. {cnName: "年级专业名称", enName: "majorGradeName",width:200},
  172. {cnName: "所属单位", enName: "practiceBaseName",width:200},
  173. {cnName: "岗位名称", enName: "name",width:200},
  174. {cnName: "岗位数量", enName: "qty",width:100},
  175. {cnName: "备注", enName: "remark",width:150}],
  176. template: {
  177. tempFileName: "岗位导入模板.xlsx",
  178. url: '',
  179. params: null
  180. }
  181. });
  182. getDictionaryItemList({code: "PracticeBaseType"}).then(x => {
  183. practiceBaseTypeList.value = x.filter(f => f.value != 3).map(x => ({
  184. label: x.name,
  185. value: x.value
  186. }));
  187. })
  188. const filterOption = (input: string, option: any) => {
  189. return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
  190. };
  191. const data = ref([]);
  192. const pagination = computed(() => ({
  193. total: formState.total,
  194. current: formState.page,
  195. pageSize: formState.rows,
  196. showSizeChanger: true,
  197. showTotal: total => getPaginationTotalTitle(total)
  198. }));
  199. const loading = ref(false);
  200. const handleTableChange: TableProps['onChange'] = (
  201. pag: { pageSize: number; current: number },
  202. ) => {
  203. formState.page = pag.current;
  204. formState.rows = pag.pageSize;
  205. loadData();
  206. };
  207. const onFinish = () => {
  208. loadData();
  209. }
  210. const loadData = async function () {
  211. loading.value = true;
  212. const result: any = await get('position/getList', formState);
  213. data.value = result.list;
  214. formState.total = result.total;
  215. loading.value = false;
  216. }
  217. const onDelete = () => {
  218. if (selectedRowKeys.value.length <= 0) {
  219. message.warning('请选择需要删除的数据!');
  220. return false;
  221. }
  222. postdel('position/deletePosition', selectedRowKeys.value).then(() => {
  223. loadData();
  224. })
  225. };
  226. const detail = (key: string) => {
  227. tabsViewStore.addTabByPath('/position/detail', {id: key});
  228. };
  229. const add = () => {
  230. //tabsViewStore.addTabByPath('/position/edit', {});
  231. tabsViewStore.addTabByPath('/query/index', {tempId: 'af029fdd-62ca-443e-9503-f940f40a7fdc'});
  232. };
  233. const edit = (key: string) => {
  234. tabsViewStore.addTabByPath('/position/edit', {id: key});
  235. };
  236. const onSelectChange = (keys: any) => {
  237. selectedRowKeys.value = keys;
  238. };
  239. return {
  240. router,
  241. route,
  242. expand,transferOk,selectKeys,
  243. formRef,
  244. formState,
  245. columns,data,loading,selectedRowKeys,
  246. pagination,practiceBaseTypeList,majorGradeList,schoolYearList,
  247. handleTableChange,
  248. onSelectChange,
  249. onFinish,
  250. loadData,
  251. detail,
  252. add,
  253. edit,onDelete,filterOption,
  254. importOptions
  255. };
  256. },
  257. created() {
  258. this.loadData();
  259. },
  260. activated() {
  261. if (history.state.params?.reload)
  262. this.loadData();
  263. }
  264. });
  265. </script>