index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <div class="table_total">
  3. <div class="table_header">
  4. <!-- <p>单表</p>
  5. <el-divider></el-divider> -->
  6. <div class="table_headerBtun" v-if="queryData.buttonList">
  7. <el-button type="primary" plain @click="headerBtn(item)" v-for="(item,index) in queryData.buttonList.split('')"
  8. :key="index">{{item | btnConversion}}</el-button>
  9. </div>
  10. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  11. <dynamic-form :ref="item.columnName" :config="queryParams" @inputs="changeFn" :formConfig="item" v-for="(item,index) in queryData.queryList"
  12. :key='index' />
  13. <el-form-item>
  14. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. </div>
  19. <!-- 内容 -->
  20. <div class="table_nav">
  21. <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
  22. <el-table-column type="selection" width="55" align="center" />
  23. <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" v-for="(item,index) in tabData"
  24. :key="index" />
  25. </el-table>
  26. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  27. @pagination="getList" />
  28. </div>
  29. </div>
  30. </template>
  31. <script>
  32. import {
  33. tableQuery,
  34. getQueryList,
  35. addbjectSave,
  36. getByTableName,
  37. delMenu,
  38. getObject
  39. } from '@/api/system/table.js'
  40. import {
  41. mapGetters,
  42. mapState
  43. } from "vuex";
  44. export default {
  45. name: "index",
  46. data() {
  47. return {
  48. tabData: [],
  49. multiple: true,
  50. single: true,
  51. open: false,
  52. // 遮罩层
  53. loading: true,
  54. total: 0,
  55. // 岗位表格数据
  56. postList: [],
  57. // 显示搜索条件
  58. showSearch: true,
  59. activeNames: ['1'],
  60. title: '',
  61. queryData: {},
  62. tabName: '',
  63. form: {
  64. table: '',
  65. objId: -1,
  66. fixedData: {
  67. condition: {
  68. }
  69. }
  70. },
  71. // 查询参数
  72. queryParams: {
  73. table: '',
  74. pageNo: 1,
  75. isUi: false,
  76. pageSize: 10,
  77. orderBy: 'create_time desc',
  78. fixedData: {
  79. condition: {
  80. }
  81. }
  82. }
  83. };
  84. },
  85. filters: {
  86. btnConversion(val) {
  87. switch (val) {
  88. case 'A':
  89. return '新增';
  90. case 'M':
  91. return '修改';
  92. case 'D':
  93. return '删除';
  94. case 'Q':
  95. return '查询';
  96. case 'S':
  97. return '提交';
  98. case 'U':
  99. return '反提交';
  100. case 'I':
  101. return '导入';
  102. case 'E':
  103. return '导出';
  104. }
  105. }
  106. },
  107. computed: {
  108. ...mapGetters(["sidebarRouters", "sidebar", "tabIndex"]),
  109. },
  110. mounted() {
  111. const route = this.$route;
  112. const {
  113. meta,
  114. path
  115. } = route;
  116. let items = this.sidebarRouters.filter(res => {
  117. return res.path == ('/'+ path.split('/')[1])
  118. })[0].children.filter(res => {
  119. return res.path == path.split('/')[2]
  120. })[0]
  121. this.tabName = items.sysTableName
  122. this.queryParams.table = items.sysTableName
  123. this.form.table = items.sysTableName
  124. console.log(this.sidebarRouters,items,path,998812111)
  125. this.init();
  126. this.getList();
  127. },
  128. methods: {
  129. routerFn(id,tables) {
  130. if(this.queryData.viewType == 'crud'){
  131. this.$router.push({
  132. path: '/business/table',
  133. query: {
  134. id,
  135. tables,
  136. },
  137. })
  138. }else if(this.queryData.viewType == 'headTab') {
  139. this.$router.push({
  140. path: '/business/editing',
  141. query: {
  142. id,
  143. tables,
  144. },
  145. })
  146. }else if(this.queryData.viewType == 'itemTab'){
  147. this.$router.push({
  148. path: '/business/form',
  149. query: {
  150. id,
  151. tables,
  152. },
  153. })
  154. }
  155. },
  156. headerBtn(item) {
  157. switch (item) {
  158. case 'A':
  159. {
  160. this.routerFn(-1,this.tabName)
  161. return
  162. }
  163. case 'M':
  164. {
  165. if (this.single) {
  166. this.msgInfo('请勾选一条信息')
  167. return
  168. }
  169. const id = this.ids.join(',')
  170. this.routerFn(id,this.tabName)
  171. return
  172. }
  173. case 'D':
  174. {
  175. if (this.multiple) {
  176. this.msgInfo('请勾选一条信息')
  177. return
  178. }
  179. delMenu({
  180. table: this.tabName,
  181. idList: this.ids
  182. }).then(res => {
  183. this.msgSuccess('删除成功')
  184. this.getList()
  185. })
  186. return
  187. }
  188. case 'Q':
  189. {
  190. this.handleQuery()
  191. return
  192. }
  193. case 'S':
  194. {
  195. return
  196. }
  197. case 'U':
  198. {
  199. return
  200. }
  201. case 'E':
  202. {
  203. this.handleExport()
  204. return
  205. }
  206. }
  207. },
  208. // 取消按钮
  209. cancel() {
  210. this.open = false;
  211. this.reset();
  212. },
  213. /** 导出按钮操作 */
  214. handleExport() {
  215. this.download('system/post/export', {
  216. ...this.queryParams
  217. }, `post_${new Date().getTime()}.xlsx`)
  218. },
  219. // 多选框选中数据
  220. handleSelectionChange(selection) {
  221. this.ids = selection.map(item => item.id)
  222. this.single = selection.length != 1
  223. this.multiple = !selection.length
  224. },
  225. changeFn(obj) {
  226. for (let key in obj) {
  227. this.queryParams.fixedData.condition[key] = obj[key]
  228. }
  229. },
  230. // 表单重置
  231. reset() {
  232. this.form = {
  233. table: this.tabName,
  234. objId: '',
  235. fixedData: {
  236. condition: {
  237. }
  238. },
  239. };
  240. this.resetForm("form");
  241. },
  242. resetQuery() {
  243. this.resetForm("queryForm");
  244. this.handleQuery();
  245. },
  246. /** 搜索按钮操作 */
  247. handleQuery() {
  248. this.queryParams.pageNo = 1;
  249. this.grabFn(this.queryData.queryList, this.queryParams.fixedData.condition)
  250. this.getList();
  251. },
  252. // 抓取参数
  253. grabFn(arr, parForm) {
  254. for (let item of arr) {
  255. if (item.htmlType == 'checkbox' || item.htmlType == 'imageUpload' || item.htmlType == 'fileUpload') {
  256. if (this.$refs[item.columnName][0].config.length) {
  257. parForm[item.columnName] = this.$refs[item.columnName][0].config
  258. }
  259. } else {
  260. parForm[item.columnName] = this.$refs[item.columnName][0].config[item.columnName]
  261. }
  262. }
  263. },
  264. getList() {
  265. getQueryList(this.queryParams).then(response => {
  266. this.total = response.data.total;
  267. this.tabData = response.data.tableHeadList
  268. this.postList = response.data.rows;
  269. this.loading = false;
  270. });
  271. },
  272. init() {
  273. tableQuery({
  274. table: this.tabName,
  275. }).then(res => {
  276. let data = res.data
  277. this.queryData = data
  278. })
  279. },
  280. handleChange(val) {
  281. }
  282. },
  283. };
  284. </script>
  285. <style lang="scss">
  286. .table_header {
  287. .el-divider--horizontal {
  288. margin-top: 16px;
  289. }
  290. .table_headerBtun {
  291. margin-bottom: 20px;
  292. }
  293. }
  294. .table_nav {
  295. .el-collapse-item__wrap {
  296. border-bottom: 0;
  297. }
  298. .el-collapse-item__header {
  299. border-bottom: 0;
  300. font-size: 15px;
  301. font-family: PingFang SC;
  302. font-weight: bold;
  303. color: #3C8DBC;
  304. line-height: 36px;
  305. }
  306. // .el-form-item__content {
  307. // width: 55%;
  308. // }
  309. .el-collapse {
  310. border-top: 0;
  311. }
  312. }
  313. </style>
  314. <style scoped lang="scss">
  315. .app-main {
  316. // background-color: #eef0ff !important;
  317. }
  318. .table_total {
  319. background-color: #eef0ff;
  320. min-height: calc(100vh - 94px);
  321. padding: 20px;
  322. // 头部
  323. .table_header {
  324. background-color: #fff;
  325. border-radius: 6px;
  326. padding: 23px 23px 0px;
  327. margin-bottom: 20px;
  328. p {
  329. font-size: 15px;
  330. font-weight: bold;
  331. color: #3C8DBC;
  332. line-height: 36px;
  333. }
  334. p::before {
  335. content: "";
  336. display: block;
  337. width: 18px;
  338. height: 8px;
  339. background: #3C8DBC;
  340. border-radius: 3px;
  341. }
  342. }
  343. // 内容
  344. .table_nav {
  345. background-color: #fff;
  346. border-radius: 6px;
  347. padding: 23px;
  348. }
  349. }
  350. p {
  351. margin: 0;
  352. }
  353. </style>