index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. <template>
  2. <div class="tabForm">
  3. <div class="tabForm_header">
  4. <div class="table_headerBtun" v-if="queryData.buttonList">
  5. <el-button type="primary" size="small" plain @click="handleQuery(item)" v-for="(item,index) in queryData.buttonList.split('')" :key="index">{{item | btnConversion}}</el-button>
  6. </div>
  7. </div>
  8. <!-- 内容 -->
  9. <div class="table_nav">
  10. <el-collapse v-model="activeNames">
  11. <el-collapse-item :title="item.columnComment" :name="index" v-for="(item,index) in queryData.showData" :key="index" class="eitde">
  12. <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="120px">
  13. <el-row :gutter="0">
  14. <el-col :span="24" :key="index">
  15. <dynamic-forms :ref="items.columnName" :config="queryParams" @inputs = "changeFn" :formConfig="items" v-for="(items,indexs) in item.hrChildren" :key='indexs' />
  16. </el-col>
  17. </el-row>
  18. </el-form>
  19. </el-collapse-item>
  20. <!-- 列表 -->
  21. <el-collapse-item :title="title" name="index" class="eitde" v-if="tabShoes">
  22. <div class="ppl">
  23. <p v-for="(item,index) in tabldie" :key="index" @click="enditTab(index)">
  24. <img src="../../../assets/images/icon_tbtab_normal.png" alt="" class="index_headerImg" v-if="numtab !== index">
  25. <img src="../../../assets/images/icon_tbtab_selected.png" alt="" class="index_headerImg" v-if="numtab == index">
  26. <span :class="[index == numtab ? 'span' : '']">{{item.tableComment}}</span>
  27. </p>
  28. </div>
  29. <el-divider></el-divider>
  30. <el-table stripe v-loading="loading" :data="postList.rows" @selection-change="handleSelectionChange">
  31. <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" v-for="(item,index) in postList.tableHeadList" :key="index" />
  32. </el-table>
  33. <div class="index_haderPagin">
  34. <pagination
  35. v-show="total>0"
  36. :total="total"
  37. :page.sync="queryParamslist.pageNo"
  38. :limit.sync="queryParamslist.pageSize"
  39. @pagination="foremliseju"
  40. />
  41. <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage3"
  42. :page-size="queryParamslist.pageSize" layout="prev, pager, next, jumper" v-show="total>0"
  43. :total="total" @pagination="foremliseju">
  44. </el-pagination> -->
  45. </div>
  46. </el-collapse-item>
  47. </el-collapse>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import {
  53. getTableQuery,
  54. getObject,
  55. geteditindeTab,
  56. listIndex,
  57. delMenutabform,
  58. tableSubimt, tableSubimtanit, addbjectSave
  59. } from '@/api/system/form.js'
  60. export default {
  61. name: "index",
  62. data() {
  63. return {
  64. num: 0,
  65. // 总条数
  66. total: 0,
  67. loading:true,
  68. tabList: {},
  69. currentPage3: 0,
  70. activeNames: [1],
  71. title: '列表',
  72. objParams: {
  73. table: 'obj_test',
  74. fixedData: {
  75. id: -1
  76. },
  77. isUi:true
  78. },
  79. queryData: {},
  80. // 查询参数
  81. queryParams: {
  82. dictName: undefined,
  83. dictType: undefined,
  84. status: undefined
  85. },
  86. queryParamslist: {
  87. pageNo: 1,
  88. pageSize: 10,
  89. orderBy:'create_time desc',
  90. table: '',
  91. },
  92. labletit: '查询参数1233',
  93. surlable: '实际数据库表',
  94. postList: {},
  95. numtab: 0,
  96. tabldie:[],
  97. tabShoes:false,//tab 显示隐藏
  98. tableZbietabg:{
  99. table:'sys_user'
  100. },
  101. forme:{
  102. table:'',
  103. fixedData:{}
  104. },
  105. formeanti:{
  106. table:'',
  107. commitData:[],
  108. },
  109. formy:{
  110. id:0,
  111. status:1
  112. },
  113. // 删除参数
  114. deledlid:{
  115. table:'',
  116. idList:[]
  117. }
  118. };
  119. },
  120. filters:{
  121. btnConversion(val) {
  122. switch(val){
  123. case 'A':
  124. return '新增';
  125. case 'M':
  126. return '修改';
  127. case 'D':
  128. return '删除';
  129. case 'Q':
  130. return '查询';
  131. case 'S':
  132. return '提交';
  133. case 'U':
  134. return '反提交';
  135. case 'I':
  136. return '导入';
  137. case 'E':
  138. return '导出';
  139. }
  140. }
  141. },
  142. mounted() {
  143. this.formeanti.table = this.$route.query.tables
  144. this.forme.table = this.$route.query.tables
  145. this.forme.objId = this.$route.query.id
  146. this.formy.id = this.$route.query.id
  147. this.tableZbietabg.table = this.$route.query.tables
  148. this.objParams.table = this.$route.query.tables
  149. this.objParams.fixedData.id = this.$route.query.id
  150. this.deledlid.table = this.$route.query.tables
  151. this.deledlid.idList.push(this.$route.query.id)
  152. this.queryParamslist.table = this.$route.query.tables
  153. this.init()
  154. this.edingelsietab()
  155. },
  156. methods: {
  157. handleCurrentChange() {
  158. },
  159. handleSizeChange() {
  160. },
  161. handleSelectionChange() {
  162. },
  163. headerBtn(item) {
  164. switch(item) {
  165. case 'A': {
  166. return
  167. }
  168. case 'M': {
  169. return
  170. }
  171. case 'D': {
  172. return
  173. }
  174. case 'Q': {
  175. return
  176. }
  177. case 'S': {
  178. return
  179. }
  180. case 'U': {
  181. return
  182. }
  183. case 'E': {
  184. return
  185. }
  186. }
  187. },
  188. init() {
  189. getObject(this.objParams).then(res => {
  190. console.log(res)
  191. let data = res.data
  192. this.queryData = data
  193. console.log(this.queryData,567)
  194. })
  195. },
  196. // tab数据
  197. edingelsietab(){
  198. console.log(4566)
  199. geteditindeTab(this.tableZbietabg).then(response => {
  200. if(response.data.ref.length !==0){
  201. this.tabldie = response.data.ref
  202. this.tabShoes = true
  203. this.foremliseju()
  204. }else{
  205. this.tabShoes = false
  206. }
  207. // this.msgSuccess("反提交成功");
  208. // this.open = false;
  209. // this.getList();
  210. });
  211. },
  212. // 列表数据
  213. foremliseju(){
  214. listIndex(this.queryParamslist).then(res => {
  215. console.log(res)
  216. let data = res.data
  217. this.postList = data
  218. this.loading = false
  219. this.total = res.data.total - 0
  220. console.log(this.total)
  221. console.log(this.postList,567)
  222. })
  223. },
  224. // tab点击
  225. tabSbu(index) {
  226. this.num = index
  227. },
  228. enditTab(index) {
  229. this.numtab = index
  230. this.queryParamslist.table = this.tabldie[index].tableName
  231. this.foremliseju()
  232. },
  233. changeFn(obj) {
  234. for(let key in obj){
  235. this.queryParams[key] = obj[key]
  236. }
  237. },
  238. resetQuery() {
  239. },
  240. /** 搜索按钮操作 */
  241. handleQuery(index) {
  242. console.log(index,4)
  243. for(let item of this.queryData.showData){
  244. for(var i = 0 ; i < item.hrChildren.length ; i++){
  245. if(item.hrChildren[i].htmlType == 'checkbox' || item.hrChildren[i].htmlType == 'imageUpload' || item.hrChildren[i].htmlType == 'fileUpload'){
  246. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config
  247. } else{
  248. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config[item.hrChildren[i].columnName]
  249. }
  250. }
  251. }
  252. this.queryParams.image = JSON.stringify(this.queryParams.image)
  253. this.queryParams.file = JSON.stringify(this.queryParams.file)
  254. console.log(this.queryParams)
  255. if(index == 'D'){
  256. //删除
  257. this.handleDelete(this.deledlid)
  258. }else if(index == 'S'){
  259. //提交 保存
  260. // this.formeanti.table = 'obj_test'
  261. this.formeanti.commitData = []
  262. this.formy.status = 1
  263. // this.formy.id = 0
  264. this.formeanti.commitData.push(this.formy)
  265. console.log(this.formeanti)
  266. this.antiSubmission()
  267. }else if(index == 'U'){
  268. //反提交 保存
  269. // this.formeanti.table = 'obj_test'
  270. this.formeanti.commitData = []
  271. this.formy.status = 2
  272. // this.formy.id = 0
  273. this.formeanti.commitData.push(this.formy)
  274. console.log(this.formeanti)
  275. this.antiSubmission()
  276. }else if(index == 'M'){
  277. // 修改
  278. // this.forme.table = 'obj_test'
  279. // this.forme.objId = 1
  280. this.forme.fixedData = this.queryParams
  281. this.submitForm()
  282. }else if(index == 'A'){
  283. //新增
  284. // this.forme.table = 'obj_test'
  285. // this.forme.objId = -1
  286. this.forme.fixedData = this.queryParams
  287. this.submitForm()
  288. }
  289. console.log(this.forme)
  290. // this.getList();
  291. },
  292. /** 新增 修改提交按钮 */
  293. submitForm: function() {
  294. addbjectSave(this.forme).then(response => {
  295. this.msgSuccess("保存成功");
  296. this.open = false;
  297. this.$router.go(-1)
  298. // this.getList();
  299. });
  300. },
  301. // 提交反提交
  302. antiSubmission(){
  303. if (this.formy.status == 1) {
  304. // 提交
  305. tableSubimt(this.formeanti).then(response => {
  306. this.msgSuccess("提交成功");
  307. this.$router.go(-1)
  308. // this.open = false;
  309. // this.getList();
  310. });
  311. } else if(this.formy.status == 2){
  312. // 反提交
  313. tableSubimtanit(this.formeanti).then(response => {
  314. this.msgSuccess("反提交成功");
  315. this.$router.go(-1)
  316. // this.open = false;
  317. // this.getList();
  318. });
  319. }
  320. },
  321. //删除
  322. handleDelete(index) {
  323. this.$confirm('是否确认删除', "警告", {
  324. confirmButtonText: "确定",
  325. cancelButtonText: "取消",
  326. type: "warning"
  327. }).then(function() {
  328. return delMenutabform(index);
  329. }).then(() => {
  330. // this.getList();
  331. this.msgSuccess("删除成功");
  332. this.$router.go(-1)
  333. })
  334. }
  335. },
  336. };
  337. </script>
  338. <style lang="scss">
  339. .tabForm {
  340. .el-collapse-item__content {
  341. padding: 0;
  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. .el-divider--horizontal {
  362. margin-top: 0;
  363. }
  364. .eitde {
  365. background-color: #fff;
  366. border-radius: 6px;
  367. padding: 23px;
  368. margin-bottom: 20px;
  369. }
  370. }
  371. }
  372. </style>
  373. <style scoped lang="scss">
  374. .tabForm {
  375. background-color: #eef0ff;
  376. height: 100%;
  377. padding: 20px;
  378. p {
  379. margin: 0;
  380. }
  381. // 头部
  382. .tabForm_header {
  383. background-color: #fff;
  384. border-radius: 6px;
  385. padding: 23px;
  386. margin-bottom: 20px;
  387. }
  388. // 内容
  389. .table_nav {
  390. // background-color: #fff;
  391. // border-radius: 6px;
  392. // padding: 23px;
  393. .ppl {
  394. display: flex;
  395. height: 38px;
  396. p {
  397. position: relative;
  398. width: 113px;
  399. height: 38px;
  400. img {
  401. position: absolute;
  402. top: 0;
  403. left: 0;
  404. width: 100%;
  405. height: 100%;
  406. // z-index: -1;
  407. }
  408. span {
  409. width: 100%;
  410. position: absolute;
  411. top: 0;
  412. left: 0;
  413. // transform: translate(-50%);
  414. text-align: center;
  415. line-height: 38px;
  416. font-size: 15px;
  417. font-family: PingFang SC;
  418. font-weight: bold;
  419. color: #aaa;
  420. }
  421. .span {
  422. color: #3C8DBC;
  423. }
  424. }
  425. }
  426. }
  427. }
  428. // tab
  429. .index_headetab {
  430. display: flex;
  431. border-bottom: 1px solid #E5E5E5;
  432. height: 53px;
  433. // padding-top: 20px;
  434. padding-bottom: 10px;
  435. margin-bottom: 20px !important;
  436. span {
  437. width: 70px;
  438. text-align: center;
  439. line-height: 53px;
  440. height: 53px;
  441. font-size: 15px;
  442. font-family: PingFang SC;
  443. font-weight: bold;
  444. color: #666;
  445. position: relative;
  446. // flex: 1;
  447. // border-bottom: ;
  448. }
  449. .span {
  450. content: '';
  451. display: block;
  452. width: 18px;
  453. height: 8px;
  454. border-radius: 3px;
  455. background-color: #3C8DBC;
  456. color: #3C8DBC !important;
  457. // position: absolute;
  458. // border-bottom: ;
  459. }
  460. .spanto {
  461. color: #3C8DBC;
  462. border-bottom: 3px solid #3C8DBC;
  463. }
  464. }
  465. </style>