4781dda697f13673c6bf406948897675c1b442f4.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8. <a-form-item label="用户名">
  9. <j-input placeholder="请输入名称模糊查询" v-model="queryParam.name"></j-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13. <a-form-item label="年龄">
  14. <!-- <a-input placeholder="请输入名称查询" v-model="queryParam.age"></a-input>-->
  15. <a-input placeholder="最小年龄" type="ge" v-model="queryParam.age_begin" style="width:calc(50% - 15px);"></a-input>
  16. <span class="group-query-strig">~</span>
  17. <a-input placeholder="最大年龄" type="le" v-model="queryParam.age_end" style="width:calc(50% - 15px);"></a-input>
  18. </a-form-item>
  19. </a-col>
  20. <template v-if="toggleSearchStatus">
  21. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  22. <a-form-item label="生日">
  23. <a-range-picker v-model="queryParam.birthdayRange"
  24. format="YYYY-MM-DD"
  25. :placeholder="['开始时间', '结束时间']"
  26. @change="onBirthdayChange" />
  27. </a-form-item>
  28. </a-col>
  29. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  30. <a-form-item label="性别">
  31. <j-dict-select-tag v-model="queryParam.sex" placeholder="请选择性别" dictCode="sex"/>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  35. <a-form-item label="选择用户">
  36. <j-dict-select-tag v-model="queryParam.id" placeholder="请选择用户" dictCode="demo,name,id"/>
  37. </a-form-item>
  38. </a-col>
  39. </template>
  40. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  41. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  42. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  43. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  44. <a @click="handleToggleSearch" style="margin-left: 8px">
  45. {{ toggleSearchStatus ? '收起' : '展开' }}
  46. <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
  47. </a>
  48. </a-col>
  49. </span>
  50. </a-row>
  51. </a-form>
  52. </div>
  53. <!-- 操作按钮区域 -->
  54. <div class="table-operator">
  55. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  56. <a-button type="primary" icon="plus" @click="jump">创建单据</a-button>
  57. <a-button type="primary" icon="plus" @click="onetomany">一对多</a-button>
  58. <a-button type="primary" icon="download" @click="handleExportXls('单表示例')">导出</a-button>
  59. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  60. <a-button type="primary" icon="import">导入</a-button>
  61. </a-upload>
  62. <!-- 高级查询区域 -->
  63. <j-super-query :fieldList="fieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
  64. <a-dropdown v-if="selectedRowKeys.length > 0">
  65. <a-menu slot="overlay">
  66. <a-menu-item key="1" @click="batchDel">
  67. <a-icon type="delete"/>
  68. 删除
  69. </a-menu-item>
  70. </a-menu>
  71. <a-button style="margin-left: 8px"> 批量操作
  72. <a-icon type="down"/>
  73. </a-button>
  74. </a-dropdown>
  75. </div>
  76. <!-- table区域-begin -->
  77. <div>
  78. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  79. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
  80. selectedRowKeys.length }}</a>项
  81. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  82. <span style="float:right;">
  83. <a @click="loadData()"><a-icon type="sync" />刷新</a>
  84. <a-divider type="vertical" />
  85. <a-popover title="自定义列" trigger="click" placement="leftBottom">
  86. <template slot="content">
  87. <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
  88. <a-row style="width: 400px">
  89. <template v-for="(item,index) in defColumns">
  90. <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
  91. <a-col :span="12"><a-checkbox :value="item.dataIndex"><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox></a-col>
  92. </template>
  93. </template>
  94. </a-row>
  95. </a-checkbox-group>
  96. </template>
  97. <a><a-icon type="setting" />设置</a>
  98. </a-popover>
  99. </span>
  100. </div>
  101. <a-table
  102. ref="table"
  103. size="middle"
  104. bordered
  105. rowKey="id"
  106. :columns="columns"
  107. :dataSource="dataSource"
  108. :pagination="ipagination"
  109. :loading="loading"
  110. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  111. @change="handleTableChange">
  112. <div slot="filterDropdown">
  113. <a-card>
  114. <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
  115. <a-row style="width: 400px">
  116. <template v-for="(item,index) in defColumns">
  117. <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
  118. <a-col :span="12"><a-checkbox :value="item.dataIndex"><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox></a-col>
  119. </template>
  120. </template>
  121. </a-row>
  122. </a-checkbox-group>
  123. </a-card>
  124. </div>
  125. <a-icon slot="filterIcon" type='setting' :style="{ fontSize:'16px',color: '#108ee9' }" />
  126. <span slot="action" slot-scope="text, record">
  127. <a @click="handleEdit(record)">编辑</a>
  128. <a-divider type="vertical"/>
  129. <a-dropdown>
  130. <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
  131. <a-menu slot="overlay">
  132. <a-menu-item>
  133. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  134. <a>删除</a>
  135. </a-popconfirm>
  136. </a-menu-item>
  137. </a-menu>
  138. </a-dropdown>
  139. </span>
  140. </a-table>
  141. </div>
  142. <!-- table区域-end -->
  143. <!-- 表单区域 -->
  144. <jeecgDemo-modal ref="modalForm" @ok="modalFormOk"></jeecgDemo-modal>
  145. <!-- 一对多表单区域 -->
  146. <JeecgDemoTabsModal ref="jeecgDemoTabsModal" @ok="modalFormOk"></JeecgDemoTabsModal>
  147. </a-card>
  148. </template>
  149. <script>
  150. import JeecgDemoModal from './modules/JeecgDemoModal'
  151. import JSuperQuery from '@/components/jeecg/JSuperQuery.vue';
  152. import JInput from '@/components/jeecg/JInput.vue';
  153. import JeecgDemoTabsModal from './modules/JeecgDemoTabsModal'
  154. import {initDictOptions, filterDictText,filterDictTextByCache} from '@/components/dict/JDictSelectUtil'
  155. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  156. import Vue from 'vue'
  157. import { filterObj } from '@/utils/util';
  158. //高级查询modal需要参数
  159. const superQueryFieldList=[
  160. {
  161. type: "string",
  162. value: "name",
  163. text: "用户名"
  164. }, {
  165. type: "int",
  166. value: "age",
  167. text: "年龄"
  168. }, {
  169. type: "date",
  170. value: "birthday",
  171. text: "生日"
  172. }
  173. ]
  174. export default {
  175. name: "JeecgDemoList",
  176. mixins:[JeecgListMixin],
  177. components: {
  178. JeecgDemoModal,
  179. JSuperQuery,
  180. JeecgDemoTabsModal,
  181. JInput
  182. },
  183. data() {
  184. return {
  185. description: '单表示例列表',
  186. //字典数组缓存
  187. sexDictOptions: [],
  188. importExcelUrl:`${window._CONFIG['domianURL']}/test/jeecgDemo/importExcel`,
  189. //表头
  190. columns:[],
  191. //列设置
  192. settingColumns:[],
  193. //列定义
  194. defColumns: [
  195. {
  196. title: '#',
  197. dataIndex: '',
  198. key: 'rowIndex',
  199. width: 60,
  200. align: "center",
  201. customRender: function (t, r, index) {
  202. return parseInt(index) + 1;
  203. }
  204. },
  205. {
  206. title: '姓名',
  207. align: "center",
  208. dataIndex: 'name'
  209. },
  210. {
  211. title: '关键词',
  212. align: "center",
  213. dataIndex: 'keyWord'
  214. },
  215. {
  216. title: '打卡时间',
  217. align: "center",
  218. dataIndex: 'punchTime'
  219. },
  220. {
  221. title: '性别',
  222. align: "center",
  223. dataIndex: 'sex',
  224. customRender: (text) => {
  225. //字典值替换通用方法
  226. return filterDictTextByCache('sex', text);
  227. }
  228. },
  229. {
  230. title: '年龄',
  231. align: "center",
  232. dataIndex: 'age'
  233. },
  234. {
  235. title: '生日',
  236. align: "center",
  237. dataIndex: 'birthday'
  238. },
  239. {
  240. title: '邮箱',
  241. align: "center",
  242. dataIndex: 'email'
  243. },
  244. {
  245. title: '个人简介',
  246. align: "center",
  247. dataIndex: 'content'
  248. },
  249. {
  250. title: '操作',
  251. dataIndex: 'action',
  252. align: "center",
  253. scopedSlots: {
  254. filterDropdown: 'filterDropdown',
  255. filterIcon: 'filterIcon',
  256. customRender: 'action'},
  257. }
  258. ],
  259. url: {
  260. list: "/test/jeecgDemo/list",
  261. delete: "/test/jeecgDemo/delete",
  262. deleteBatch: "/test/jeecgDemo/deleteBatch",
  263. exportXlsUrl: "/test/jeecgDemo/exportXls"
  264. },
  265. fieldList:superQueryFieldList
  266. }
  267. },
  268. methods: {
  269. getQueryParams(){
  270. //高级查询器
  271. let sqp = {}
  272. if(this.superQueryParams){
  273. sqp['superQueryParams']=encodeURI(this.superQueryParams)
  274. sqp['superQueryMatchType'] = this.superQueryMatchType
  275. }
  276. var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
  277. param.field = this.getQueryField();
  278. param.pageNo = this.ipagination.current;
  279. param.pageSize = this.ipagination.pageSize;
  280. delete param.birthdayRange; //范围参数不传递后台
  281. return filterObj(param);
  282. },
  283. initDictConfig() {
  284. console.log("--我才是真的方法!--")
  285. //初始化字典 - 性别
  286. initDictOptions('sex').then((res) => {
  287. if (res.success) {
  288. this.sexDictOptions = res.result;
  289. }
  290. });
  291. },
  292. onetomany: function () {
  293. this.$refs.jeecgDemoTabsModal.add();
  294. this.$refs.jeecgDemoTabsModal.title = "编辑";
  295. },
  296. //跳转单据页面
  297. jump() {
  298. this.$router.push({path: '/jeecg/helloworld'})
  299. },
  300. onBirthdayChange: function (value, dateString) {
  301. console.log(dateString[0],dateString[1]);
  302. this.queryParam.birthday_begin=dateString[0];
  303. this.queryParam.birthday_end=dateString[1];
  304. },
  305. //列设置更改事件
  306. onColSettingsChange (checkedValues) {
  307. var key = this.$route.name+":colsettings";
  308. Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
  309. this.settingColumns = checkedValues;
  310. const cols = this.defColumns.filter(item => {
  311. if(item.key =='rowIndex'|| item.dataIndex=='action'){
  312. return true
  313. }
  314. if (this.settingColumns.includes(item.dataIndex)) {
  315. return true
  316. }
  317. return false
  318. })
  319. this.columns = cols;
  320. },
  321. initColumns(){
  322. //权限过滤(列权限控制时打开,修改第二个参数为授权码前缀)
  323. //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');
  324. var key = this.$route.name+":colsettings";
  325. let colSettings= Vue.ls.get(key);
  326. if(colSettings==null||colSettings==undefined){
  327. let allSettingColumns = [];
  328. this.defColumns.forEach(function (item,i,array ) {
  329. allSettingColumns.push(item.dataIndex);
  330. })
  331. this.settingColumns = allSettingColumns;
  332. this.columns = this.defColumns;
  333. }else{
  334. this.settingColumns = colSettings;
  335. const cols = this.defColumns.filter(item => {
  336. if(item.key =='rowIndex'|| item.dataIndex=='action'){
  337. return true;
  338. }
  339. if (colSettings.includes(item.dataIndex)) {
  340. return true;
  341. }
  342. return false;
  343. })
  344. this.columns = cols;
  345. }
  346. }
  347. },
  348. created() {
  349. this.initColumns();
  350. },
  351. }
  352. </script>
  353. <style scoped>
  354. @import '~@assets/less/common.less';
  355. </style>