index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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. this.jeigneutwo.push(route)
  172. } else if (route == 'S') {
  173. route = '提交'
  174. if (this.formy.id != -1) {
  175. this.jeigneutwo.push(route)
  176. }
  177. } else if (route == 'U') {
  178. route = '反提交'
  179. if (this.formy.id != -1) {
  180. this.jeigneutwo.push(route)
  181. }
  182. } else if (route == 'I') {
  183. route = '导入'
  184. this.jeigneutwo.push(route)
  185. } else if (route == 'E') {
  186. route = '导出'
  187. this.jeigneutwo.push(route)
  188. }
  189. })
  190. this.jeigneutwo.push('刷新')
  191. this.jeigneutwo.push('返回')
  192. console.log(this.queryData, 567)
  193. // 图片的显示隐藏
  194. if(this.queryData.showData.length !==0){
  195. this.queryData.showData.filter(route => {
  196. if(route.hrChildren.length !== 0){
  197. if(route.hrChildren[0].readonly !== null){
  198. if(route.hrChildren[0].readonly == true){
  199. this.imgShoew = true
  200. }else{
  201. this.imgShoew = false
  202. }
  203. }
  204. }
  205. })
  206. }
  207. })
  208. },
  209. // 数据信息
  210. edingelsie() {
  211. console.log(1234)
  212. getQueryList(
  213. this.tabledeLise
  214. ).then(res => {
  215. let data = res.data
  216. this.taleLisst = data
  217. // console.log(this.queryData.queryList)
  218. })
  219. },
  220. // tab数据
  221. edingelsietab() {
  222. console.log(4566)
  223. geteditindeTab(this.tableZbietabg).then(response => {
  224. this.tabldie = response.data.ref
  225. if (this.tabldie.length !== 0) {
  226. this.tableZbie.table = this.tabldie[0].tableName
  227. this.init()
  228. } else {
  229. this.msgSuccess("暂无tab数据");
  230. this.$router.go(-1)
  231. }
  232. // this.msgSuccess("反提交成功");
  233. // this.open = false;
  234. // this.getList();
  235. });
  236. },
  237. changeFn(obj) {
  238. for (let key in obj) {
  239. this.queryParams[key] = obj[key]
  240. }
  241. },
  242. handleQuery(index) {
  243. console.log(index, 4)
  244. for (let item of this.queryData.showData) {
  245. for (var i = 0; i < item.hrChildren.length; i++) {
  246. if (item.hrChildren[i].htmlType == 'checkbox') {
  247. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config
  248. }else if(item.hrChildren[i].htmlType == 'imageUpload' || item.hrChildren[i].htmlType == 'fileUpload'){
  249. this.queryParams[item.hrChildren[i].columnName] = JSON.stringify(this.$refs[item.hrChildren[i].columnName][0].config)
  250. } else {
  251. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config[
  252. item.hrChildren[i].columnName]
  253. }
  254. }
  255. }
  256. if (this.queryParams.pageNum !== undefined) {
  257. this.queryParams.pageNum = undefined
  258. }
  259. if (this.queryParams.pageSize !== undefined) {
  260. this.queryParams.pageSize = undefined
  261. }
  262. if (index == '删除') {
  263. //删除
  264. this.handleDelete(this.deledlid)
  265. } else if (index == '提交') {
  266. //提交 保存
  267. // this.formeanti.table = 'obj_test'
  268. this.formeanti.commitData = []
  269. this.formy.status = 1
  270. // this.formy.id = 0
  271. this.formeanti.commitData.push(this.formy)
  272. console.log(this.formeanti)
  273. this.antiSubmission()
  274. } else if (index == '反提交') {
  275. //反提交 保存
  276. // this.formeanti.table = 'obj_test'
  277. this.formeanti.commitData = []
  278. this.formy.status = 2
  279. // this.formy.id = 0
  280. this.formeanti.commitData.push(this.formy)
  281. console.log(this.formeanti)
  282. this.antiSubmission()
  283. } else if (index == '保存') {
  284. // 修改
  285. // this.forme.table = 'obj_test'
  286. // this.forme.objId = 1
  287. this.forme.fixedData = this.queryParams
  288. this.submitForm()
  289. } else if (index == '返回') {
  290. // if(this.xidugje ==0){
  291. // this.$router.go(-2)
  292. // }else{
  293. this.$router.go(-1)
  294. // }
  295. } else if (index == '刷新') {
  296. // this.xidugje = 1
  297. this.reload()
  298. }
  299. console.log(this.forme)
  300. // this.getList();
  301. },
  302. /** 新增 修改提交按钮 */
  303. submitForm: function() {
  304. console.log(3456)
  305. this.$refs["queryForm"].validate(valid => {
  306. if (valid) {
  307. addbjectSave(this.forme).then(response => {
  308. this.msgSuccess("保存成功");
  309. this.open = false;
  310. this.$router.go(-1)
  311. // this.getList();
  312. });
  313. }
  314. });
  315. },
  316. // 提交反提交
  317. antiSubmission() {
  318. this.$refs["queryForm"].validate(valid => {
  319. if (valid) {
  320. if (this.formy.status == 1) {
  321. // 提交
  322. tableSubimt(this.formeanti).then(response => {
  323. this.msgSuccess("提交成功");
  324. this.$router.go(-1)
  325. // this.open = false;
  326. // this.getList();
  327. });
  328. } else if (this.formy.status == 2) {
  329. // 反提交
  330. tableSubimtanit(this.formeanti).then(response => {
  331. this.msgSuccess("反提交成功");
  332. this.$router.go(-1)
  333. // this.open = false;
  334. // this.getList();
  335. });
  336. }
  337. }
  338. });
  339. },
  340. //删除
  341. handleDelete(index) {
  342. this.$confirm('是否确认删除', "警告", {
  343. confirmButtonText: "确定",
  344. cancelButtonText: "取消",
  345. type: "warning"
  346. }).then(function() {
  347. return delMenutab(index);
  348. }).then(() => {
  349. // this.getList();
  350. this.msgSuccess("删除成功");
  351. this.$router.go(-1)
  352. })
  353. }
  354. },
  355. };
  356. </script>
  357. <style lang="scss">
  358. .eniting_header {
  359. position: relative;
  360. .el-divider--horizontal {
  361. margin-top: 0;
  362. }
  363. }
  364. .eniting_nav {
  365. // .el-form-item{
  366. // width: 25% !important;
  367. // }
  368. .el-collapse-item__content {
  369. padding-bottom: 0;
  370. }
  371. .el-collapse-item__wrap {
  372. border-bottom: 0;
  373. }
  374. .el-collapse-item__header {
  375. border-bottom: 0;
  376. font-size: 15px;
  377. font-family: PingFang SC;
  378. font-weight: bold;
  379. color: #3C8DBC;
  380. line-height: 36px;
  381. }
  382. // .el-form-item__content{
  383. // width: 65%;
  384. // }
  385. .textarea_et {
  386. width: 95%;
  387. .el-form-item__content {
  388. width: 80%;
  389. height: 83px;
  390. .el-textarea__inner {
  391. height: 100%;
  392. }
  393. }
  394. }
  395. .textarea_etyju {
  396. width: 90%;
  397. .el-form-item__content {
  398. width: 75%;
  399. // height: 83px;
  400. .el-textarea__inner {
  401. // height: 100%;
  402. }
  403. }
  404. }
  405. .textarea_ety {
  406. width: 100%;
  407. .el-form-item__content {
  408. width: 88%;
  409. height: 150px;
  410. margin-bottom: 0;
  411. .el-textarea__inner {
  412. height: 100%;
  413. }
  414. }
  415. }
  416. .el-collapse {
  417. border-top: 0;
  418. }
  419. .eitde {
  420. background-color: #fff;
  421. border-radius: 6px;
  422. padding: 23px;
  423. margin-bottom: 20px;
  424. }
  425. }
  426. </style>
  427. <style scoped lang="scss">
  428. .eniting {
  429. p {
  430. margin: 0;
  431. }
  432. background-color: #eef0ff;
  433. height: 100%;
  434. padding: 20px;
  435. .eniting_header {
  436. background-color: #fff;
  437. border-radius: 6px;
  438. padding: 23px;
  439. margin-bottom: 20px;
  440. .p {
  441. font-size: 15px;
  442. font-weight: bold;
  443. color: #3C8DBC;
  444. line-height: 36px;
  445. margin-bottom: 0;
  446. }
  447. .p::before {
  448. content: "";
  449. display: block;
  450. width: 18px;
  451. height: 8px;
  452. background: #3C8DBC;
  453. border-radius: 3px;
  454. }
  455. .ppl {
  456. display: flex;
  457. height: 54px;
  458. p {
  459. position: relative;
  460. width: 113px;
  461. height: 38px;
  462. img {
  463. position: absolute;
  464. top: 0;
  465. left: 0;
  466. width: 100%;
  467. height: 100%;
  468. // z-index: -1;
  469. }
  470. span {
  471. width: 100%;
  472. position: absolute;
  473. top: 0;
  474. left: 0;
  475. // transform: translate(-50%);
  476. text-align: center;
  477. line-height: 38px;
  478. font-size: 15px;
  479. font-family: PingFang SC;
  480. font-weight: bold;
  481. color: #aaa;
  482. }
  483. .span {
  484. color: #3C8DBC;
  485. }
  486. }
  487. }
  488. }
  489. // 内容
  490. .eniting_nav {
  491. // background-color: #fff;
  492. // border-radius: 6px;
  493. // padding: 23px;
  494. }
  495. }
  496. .imge_tab{
  497. position: absolute;
  498. right: 0;
  499. top: 5px;
  500. }
  501. </style>