index.vue 13 KB

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