index.vue 13 KB

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