index.vue 14 KB

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