index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. <template>
  2. <div class="eniting">
  3. <!-- 头部 -->
  4. <div class="eniting_header">
  5. <!-- <p class="p">表编辑</p> -->
  6. <div class="imge_tab"><img src="../../../assets/images/pic_sy_ytj.png" alt="" v-if="imgShoew"></div>
  7. <div class="ppl">
  8. <p v-for="(item,index) in tabldie" :key="index" @click="enditTab(index)">
  9. <img src="../../../assets/images/icon_tbtab_normal.png" alt="" class="index_headerImg" v-if="num !== index">
  10. <img src="../../../assets/images/icon_tbtab_selected.png" alt="" class="index_headerImg" v-if="num == index">
  11. <span :class="[index == num ? 'span' : '']">{{item.tableComment}}</span>
  12. </p>
  13. </div>
  14. <el-divider></el-divider>
  15. <div class="table_headerBtun" v-if="queryData.buttonList">
  16. <el-button type="primary" size="small" plain v-for="(item,indexss) in jeigneutwo" :key="keyname + indexss"
  17. @click="handleQuery(item)">{{item}}</el-button>
  18. </div>
  19. </div>
  20. <!-- 内容 -->
  21. <div class="eniting_nav">
  22. <el-collapse v-model="activeNames" @change="handleChange">
  23. <el-form :rules="queryData.rules" :model="queryParams" ref="queryForm" :inline="true" label-width="120px">
  24. <el-collapse-item :title="item.columnComment" :name="index" v-for="(item,index) in queryData.showData" :key="index"
  25. class="eitde">
  26. <el-row>
  27. <el-col :span="24" :key="index">
  28. <dynamic-forms @modelFn="modelFn" :ref="items.columnName" :config="queryParams" @inputs="changeFn" :formConfig="items"
  29. v-for="(items,indexs) in item.hrChildren" :key='indexs' />
  30. </el-col>
  31. </el-row>
  32. </el-collapse-item>
  33. </el-form>
  34. </el-collapse>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import {
  40. getTableQuery,
  41. delMenutab,
  42. getQueryList,
  43. geteditindeTab,
  44. tableSubimt,
  45. tableSubimtanit,
  46. addbjectSave
  47. } from '@/api/system/table.js';
  48. export default {
  49. name: "index",
  50. inject: ['reload'],
  51. data() {
  52. return {
  53. activeNames: ['1'],
  54. title: '单表1',
  55. // 查询参数
  56. queryParams: {},
  57. labletit: '查询参数1233',
  58. num: 0,
  59. tabledeLise: {
  60. table: '',
  61. isUi: true
  62. },
  63. taleLisst: [], //列表数据
  64. // 按钮参数
  65. tableZbie: {
  66. table: 'obj_test',
  67. isUi: true,
  68. fixedData: {
  69. id: -1
  70. }
  71. },
  72. tableZbietabg: {
  73. table: 'sys_user'
  74. },
  75. queryData: {},
  76. keyname: 'nu',
  77. tabldie: [],
  78. forme: {
  79. table: '',
  80. objId: -1,
  81. fixedData: {}
  82. },
  83. formeanti: {
  84. table: '',
  85. commitData: [],
  86. },
  87. formy: {
  88. id: 0,
  89. status: 1
  90. },
  91. // 删除参数
  92. deledlid: {
  93. table: '',
  94. idList: []
  95. },
  96. jeigneu: [],
  97. jeigneutwo: [],
  98. imgShoew:false
  99. };
  100. },
  101. mounted() {
  102. // this.edingelsie()
  103. // button
  104. this.deledlid.idList = []
  105. this.formeanti.table = this.$route.query.tables
  106. // this.formeanti.id = this.$route.query.id
  107. this.forme.table = this.$route.query.tables
  108. this.forme.objId = this.$route.query.id
  109. this.tabledeLise.table = this.$route.query.tables
  110. this.tableZbie.table = this.$route.query.tables
  111. this.tableZbie.fixedData.id = this.$route.query.id
  112. this.formy.id = this.$route.query.id
  113. this.tableZbietabg.table = this.$route.query.tables
  114. this.deledlid.table = this.$route.query.tables
  115. this.deledlid.idList.push(this.$route.query.id)
  116. console.log(this.deledlid)
  117. // tab
  118. this.edingelsietab()
  119. },
  120. filters: {},
  121. methods: {
  122. modelFn(obj, cont) {
  123. this.$set(this.queryParams,obj,cont)
  124. },
  125. handleChange(val) {
  126. console.log(val);
  127. },
  128. enditTab(index) {
  129. this.num = index
  130. this.tabledeLise.table = this.tabldie[index].tableName
  131. this.formeanti.table = this.tabldie[index].tableName
  132. this.forme.table = this.tabldie[index].tableName
  133. this.tableZbie.table = this.tabldie[index].tableName
  134. // this.edingelsie()
  135. this.init()
  136. },
  137. // 按钮
  138. init() {
  139. getTableQuery(
  140. this.tableZbie
  141. ).then(res => {
  142. let data = res.data
  143. this.queryData = data
  144. this.jeigneutwo = []
  145. this.jeigneu = []
  146. this.jeigneu = data.buttonList.split('')
  147. console.log(data.buttonList)
  148. console.log(this.jeigneu)
  149. this.jeigneu.filter(route => {
  150. // route.dept_id = route.dept_id.value
  151. console.log(route)
  152. if (route == 'A') {
  153. if (this.formy.id == -1) {
  154. route = '保存'
  155. this.jeigneutwo.push(route)
  156. } else {
  157. route = '新增'
  158. }
  159. } else if (route == 'M') {
  160. route = '保存'
  161. if (this.formy.id != -1) {
  162. this.jeigneutwo.push(route)
  163. }
  164. } else if (route == 'D') {
  165. route = '删除'
  166. if (this.formy.id != -1) {
  167. this.jeigneutwo.push(route)
  168. }
  169. } else if (route == 'Q') {
  170. route = '查询'
  171. } else if (route == 'S') {
  172. route = '提交'
  173. if (this.formy.id != -1) {
  174. this.jeigneutwo.push(route)
  175. }
  176. } else if (route == 'U') {
  177. route = '反提交'
  178. if (this.formy.id != -1) {
  179. this.jeigneutwo.push(route)
  180. }
  181. } else if (route == 'I') {
  182. route = '导入'
  183. } else if (route == 'E') {
  184. route = '导出'
  185. }
  186. })
  187. this.jeigneutwo.push('刷新')
  188. this.jeigneutwo.push('返回')
  189. console.log(this.queryData, 567)
  190. // 图片的显示隐藏
  191. if(this.queryData.showData.length !==0){
  192. this.queryData.showData.filter(route => {
  193. if(route.hrChildren.length !== 0){
  194. if(route.hrChildren[1].readonly == true){
  195. this.imgShoew = true
  196. }else{
  197. this.imgShoew = false
  198. }
  199. }
  200. })
  201. }
  202. })
  203. },
  204. // 数据信息
  205. edingelsie() {
  206. console.log(1234)
  207. getQueryList(
  208. this.tabledeLise
  209. ).then(res => {
  210. let data = res.data
  211. this.taleLisst = data
  212. // console.log(this.queryData.queryList)
  213. })
  214. },
  215. // tab数据
  216. edingelsietab() {
  217. console.log(4566)
  218. geteditindeTab(this.tableZbietabg).then(response => {
  219. this.tabldie = response.data.ref
  220. if (this.tabldie.length !== 0) {
  221. this.tabledeLise.table = this.tabldie[0].tableName
  222. this.formeanti.table = this.tabldie[0].tableName
  223. this.forme.table = this.tabldie[0].tableName
  224. this.tableZbie.table = this.tabldie[0].tableName
  225. this.init()
  226. } else {
  227. this.msgSuccess("暂无tab数据");
  228. this.$router.go(-1)
  229. }
  230. // this.msgSuccess("反提交成功");
  231. // this.open = false;
  232. // this.getList();
  233. });
  234. },
  235. changeFn(obj) {
  236. for (let key in obj) {
  237. this.queryParams[key] = obj[key]
  238. }
  239. },
  240. handleQuery(index) {
  241. console.log(index, 4)
  242. for (let item of this.queryData.showData) {
  243. for (var i = 0; i < item.hrChildren.length; i++) {
  244. if (item.hrChildren[i].htmlType == 'checkbox') {
  245. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config
  246. }else if(item.hrChildren[i].htmlType == 'imageUpload' || item.hrChildren[i].htmlType == 'fileUpload'){
  247. this.queryParams[item.hrChildren[i].columnName] = JSON.stringify(this.$refs[item.hrChildren[i].columnName][0].config)
  248. } else {
  249. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config[
  250. item.hrChildren[i].columnName]
  251. }
  252. }
  253. }
  254. if (this.queryParams.pageNum !== undefined) {
  255. this.queryParams.pageNum = undefined
  256. }
  257. if (this.queryParams.pageSize !== undefined) {
  258. this.queryParams.pageSize = undefined
  259. }
  260. if (index == '删除') {
  261. //删除
  262. this.handleDelete(this.deledlid)
  263. } else if (index == '提交') {
  264. //提交 保存
  265. // this.formeanti.table = 'obj_test'
  266. this.formeanti.commitData = []
  267. this.formy.status = 1
  268. // this.formy.id = 0
  269. this.formeanti.commitData.push(this.formy)
  270. console.log(this.formeanti)
  271. this.antiSubmission()
  272. } else if (index == '反提交') {
  273. //反提交 保存
  274. // this.formeanti.table = 'obj_test'
  275. this.formeanti.commitData = []
  276. this.formy.status = 2
  277. // this.formy.id = 0
  278. this.formeanti.commitData.push(this.formy)
  279. console.log(this.formeanti)
  280. this.antiSubmission()
  281. } else if (index == '保存') {
  282. // 修改
  283. // this.forme.table = 'obj_test'
  284. // this.forme.objId = 1
  285. this.forme.fixedData = this.queryParams
  286. this.submitForm()
  287. } else if (index == '返回') {
  288. // if(this.xidugje ==0){
  289. // this.$router.go(-2)
  290. // }else{
  291. this.$router.go(-1)
  292. // }
  293. } else if (index == '刷新') {
  294. // this.xidugje = 1
  295. this.reload()
  296. }
  297. console.log(this.forme)
  298. // this.getList();
  299. },
  300. /** 新增 修改提交按钮 */
  301. submitForm: function() {
  302. this.$refs["queryForm"].validate(valid => {
  303. if (valid) {
  304. addbjectSave(this.forme).then(response => {
  305. this.msgSuccess("保存成功");
  306. this.open = false;
  307. this.$router.go(-1)
  308. // this.getList();
  309. });
  310. }
  311. });
  312. },
  313. // 提交反提交
  314. antiSubmission() {
  315. this.$refs["queryForm"].validate(valid => {
  316. if (valid) {
  317. if (this.formy.status == 1) {
  318. // 提交
  319. tableSubimt(this.formeanti).then(response => {
  320. this.msgSuccess("提交成功");
  321. this.$router.go(-1)
  322. // this.open = false;
  323. // this.getList();
  324. });
  325. } else if (this.formy.status == 2) {
  326. // 反提交
  327. tableSubimtanit(this.formeanti).then(response => {
  328. this.msgSuccess("反提交成功");
  329. this.$router.go(-1)
  330. // this.open = false;
  331. // this.getList();
  332. });
  333. }
  334. }
  335. });
  336. },
  337. //删除
  338. handleDelete(index) {
  339. this.$confirm('是否确认删除', "警告", {
  340. confirmButtonText: "确定",
  341. cancelButtonText: "取消",
  342. type: "warning"
  343. }).then(function() {
  344. return delMenutab(index);
  345. }).then(() => {
  346. // this.getList();
  347. this.msgSuccess("删除成功");
  348. this.$router.go(-1)
  349. })
  350. }
  351. },
  352. };
  353. </script>
  354. <style lang="scss">
  355. .eniting_header {
  356. position: relative;
  357. .el-divider--horizontal {
  358. margin-top: 0;
  359. }
  360. }
  361. .eniting_nav {
  362. // .el-form-item{
  363. // width: 25% !important;
  364. // }
  365. .el-collapse-item__content {
  366. padding-bottom: 0;
  367. }
  368. .el-collapse-item__wrap {
  369. border-bottom: 0;
  370. }
  371. .el-collapse-item__header {
  372. border-bottom: 0;
  373. font-size: 15px;
  374. font-family: PingFang SC;
  375. font-weight: bold;
  376. color: #3C8DBC;
  377. line-height: 36px;
  378. }
  379. // .el-form-item__content{
  380. // width: 65%;
  381. // }
  382. .textarea_et {
  383. width: 95%;
  384. .el-form-item__content {
  385. width: 80%;
  386. height: 83px;
  387. .el-textarea__inner {
  388. height: 100%;
  389. }
  390. }
  391. }
  392. .textarea_etyju {
  393. width: 90%;
  394. .el-form-item__content {
  395. width: 75%;
  396. // height: 83px;
  397. .el-textarea__inner {
  398. // height: 100%;
  399. }
  400. }
  401. }
  402. .textarea_ety {
  403. width: 100%;
  404. .el-form-item__content {
  405. width: 88%;
  406. height: 150px;
  407. margin-bottom: 0;
  408. .el-textarea__inner {
  409. height: 100%;
  410. }
  411. }
  412. }
  413. .el-collapse {
  414. border-top: 0;
  415. }
  416. .eitde {
  417. background-color: #fff;
  418. border-radius: 6px;
  419. padding: 23px;
  420. margin-bottom: 20px;
  421. }
  422. }
  423. </style>
  424. <style scoped lang="scss">
  425. .eniting {
  426. p {
  427. margin: 0;
  428. }
  429. background-color: #eef0ff;
  430. height: 100%;
  431. padding: 20px;
  432. .eniting_header {
  433. background-color: #fff;
  434. border-radius: 6px;
  435. padding: 23px;
  436. margin-bottom: 20px;
  437. .p {
  438. font-size: 15px;
  439. font-weight: bold;
  440. color: #3C8DBC;
  441. line-height: 36px;
  442. margin-bottom: 0;
  443. }
  444. .p::before {
  445. content: "";
  446. display: block;
  447. width: 18px;
  448. height: 8px;
  449. background: #3C8DBC;
  450. border-radius: 3px;
  451. }
  452. .ppl {
  453. display: flex;
  454. height: 54px;
  455. p {
  456. position: relative;
  457. width: 113px;
  458. height: 38px;
  459. img {
  460. position: absolute;
  461. top: 0;
  462. left: 0;
  463. width: 100%;
  464. height: 100%;
  465. // z-index: -1;
  466. }
  467. span {
  468. width: 100%;
  469. position: absolute;
  470. top: 0;
  471. left: 0;
  472. // transform: translate(-50%);
  473. text-align: center;
  474. line-height: 38px;
  475. font-size: 15px;
  476. font-family: PingFang SC;
  477. font-weight: bold;
  478. color: #aaa;
  479. }
  480. .span {
  481. color: #3C8DBC;
  482. }
  483. }
  484. }
  485. }
  486. // 内容
  487. .eniting_nav {
  488. // background-color: #fff;
  489. // border-radius: 6px;
  490. // padding: 23px;
  491. }
  492. }
  493. .imge_tab{
  494. position: absolute;
  495. right: 0;
  496. top: 5px;
  497. }
  498. </style>