index.vue 11 KB

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