index.vue 13 KB

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