index.vue 13 KB

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