index.vue 11 KB

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