index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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="small" plain v-for="(item,index) in queryData.buttonList.split('')" :key="index" @click="handleQuery(item)">{{item | btnConversion}}</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. data() {
  38. return {
  39. // 显示搜索条件
  40. showSearch: true,
  41. activeNames: [0],
  42. title: '单表1',
  43. tabledeLise:{
  44. table:'',
  45. isUi:true
  46. },
  47. queryData: {},
  48. // 查询参数
  49. queryParams: {
  50. },
  51. labletit: '查询参数1233',
  52. tableZbie:{
  53. table:'',
  54. isUi:true,
  55. fixedData:{
  56. id:-1
  57. }
  58. },
  59. taleLisst:[],
  60. forme:{
  61. table:'',
  62. objId:-1,
  63. fixedData:{}
  64. },
  65. formeanti:{
  66. table:'',
  67. commitData:[],
  68. },
  69. formy:{
  70. id:0,
  71. status:1
  72. },
  73. // 删除参数
  74. deledlid:{
  75. table:'',
  76. idList:[]
  77. }
  78. };
  79. },
  80. filters:{
  81. btnConversion(val) {
  82. switch(val){
  83. case 'A':
  84. return '保存';
  85. case 'M':
  86. return '保存';
  87. case 'D':
  88. return '删除';
  89. case 'Q':
  90. return '查询';
  91. case 'S':
  92. return '提交';
  93. case 'U':
  94. return '反提交';
  95. case 'I':
  96. return '导入';
  97. case 'E':
  98. return '导出';
  99. }
  100. }
  101. },
  102. mounted() {
  103. // this.tableZbie.fixedData.id = 0
  104. this.deledlid.idList = []
  105. this.formeanti.table = this.$route.query.tables
  106. // this.formeanti.id = this.$route.query.id
  107. this.forme.table = this.$route.query.tables
  108. this.forme.objId = this.$route.query.id
  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.deledlid.table = this.$route.query.tables
  113. this.deledlid.idList.push(this.$route.query.tables)
  114. console.log(this.$route.query.id)
  115. console.log(this.tableZbie.table)
  116. this.init()
  117. // this.tablsie()
  118. },
  119. methods: {
  120. changeFn(obj) {
  121. for(let key in obj){
  122. this.queryParams[key] = obj[key]
  123. }
  124. },
  125. resetQuery() {
  126. },
  127. /** 搜索按钮操作 */
  128. handleQuery(index) {
  129. console.log(index,4)
  130. for(let item of this.queryData.showData){
  131. for(var i = 0 ; i < item.hrChildren.length ; i++){
  132. if(item.hrChildren[i].htmlType == 'checkbox' || item.hrChildren[i].htmlType == 'imageUpload' || item.hrChildren[i].htmlType == 'fileUpload'){
  133. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config
  134. } else{
  135. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config[item.hrChildren[i].columnName]
  136. }
  137. }
  138. }
  139. this.queryParams.image = JSON.stringify(this.queryParams.image)
  140. this.queryParams.file = JSON.stringify(this.queryParams.file)
  141. console.log(this.queryParams)
  142. if(this.queryParams.pageNum !== undefined){
  143. this.queryParams.pageNum = undefined
  144. }
  145. if(this.queryParams.pageSize !== undefined){
  146. this.queryParams.pageSize = undefined
  147. }
  148. if(index == 'D'){
  149. //删除
  150. console.log(this.formy.id)
  151. this.handleDelete(this.deledlid)
  152. }else if(index == 'S'){
  153. //提交 保存
  154. this.formeanti.commitData = []
  155. this.formy.status = 1
  156. this.formeanti.commitData.push(this.formy)
  157. console.log(this.formeanti)
  158. this.antiSubmission()
  159. }else if(index == 'U'){
  160. //反提交 保存
  161. this.formeanti.commitData = []
  162. this.formy.status = 2
  163. this.formeanti.commitData.push(this.formy)
  164. console.log(this.formeanti)
  165. this.antiSubmission()
  166. }else if(index == 'M'){
  167. // 修改
  168. this.forme.fixedData = this.queryParams
  169. this.submitForm()
  170. }else if(index == 'A'){
  171. //新增
  172. this.forme.fixedData = this.queryParams
  173. this.submitForm()
  174. }
  175. console.log(this.forme)
  176. // this.getList();
  177. },
  178. getList() {
  179. },
  180. init() {
  181. getTableQuery(
  182. this.tableZbie
  183. ).then(res => {
  184. let data = res.data
  185. this.queryData = data
  186. console.log(this.queryData,567)
  187. })
  188. },
  189. tablsie(){
  190. console.log(1234)
  191. getQueryList(
  192. this.tabledeLise
  193. ).then(res => {
  194. let data = res.data
  195. this.taleLisst = data
  196. // console.log(this.queryData.queryList)
  197. })
  198. },
  199. handleChange(val) {
  200. console.log(val);
  201. },
  202. // 按钮点击
  203. delet(index){
  204. console.log(index)
  205. if(index == 'D'){
  206. this.handleDelete(this.formy.id)
  207. }
  208. },
  209. /** 新增 修改提交按钮 */
  210. submitForm: function() {
  211. addbjectSave(this.forme).then(response => {
  212. this.msgSuccess("保存成功");
  213. this.open = false;
  214. this.$router.go(-1)
  215. // this.getList();
  216. });
  217. },
  218. // 提交反提交
  219. antiSubmission(){
  220. if (this.formy.status == 1) {
  221. // 提交
  222. tableSubimt(this.formeanti).then(response => {
  223. this.msgSuccess("提交成功");
  224. this.$router.go(-1)
  225. // this.open = false;
  226. // this.getList();
  227. });
  228. } else if(this.formy.status == 2){
  229. // 反提交
  230. tableSubimtanit(this.formeanti).then(response => {
  231. this.msgSuccess("反提交成功");
  232. this.$router.go(-1)
  233. // this.open = false;
  234. // this.getList();
  235. });
  236. }
  237. },
  238. //删除
  239. handleDelete(index) {
  240. this.$confirm('是否确认删除', "警告", {
  241. confirmButtonText: "确定",
  242. cancelButtonText: "取消",
  243. type: "warning"
  244. }).then(function() {
  245. return delMenutab(index);
  246. }).then(() => {
  247. // this.getList();
  248. this.msgSuccess("删除成功");
  249. this.$router.go(-1)
  250. })
  251. }
  252. },
  253. };
  254. </script>
  255. <style lang="scss">
  256. .table_header{
  257. .el-divider--horizontal{
  258. margin-top: 16px;
  259. }
  260. }
  261. .headertable_nav{
  262. .el-collapse-item__wrap{
  263. border-bottom: 0;
  264. }
  265. .el-collapse-item__header{
  266. border-bottom: 0;
  267. font-size: 15px;
  268. font-family: PingFang SC;
  269. font-weight: bold;
  270. color: #3C8DBC;
  271. line-height: 36px;
  272. }
  273. // .el-form-item__content{
  274. // width: 55%;
  275. // }
  276. .el-collapse{
  277. border-top: 0;
  278. }
  279. }
  280. </style>
  281. <style scoped lang="scss">
  282. .app-main{
  283. // background-color: #eef0ff !important;
  284. }
  285. .table_total{
  286. background-color: #eef0ff;
  287. height: 100%;
  288. padding: 20px;
  289. // 头部
  290. .table_header{
  291. background-color: #fff;
  292. border-radius: 6px;
  293. padding: 23px;
  294. margin-bottom: 20px;
  295. p{
  296. font-size: 15px;
  297. font-weight: bold;
  298. color: #3C8DBC;
  299. line-height: 36px;
  300. }
  301. p::before{
  302. content: "";
  303. display: block;
  304. width: 18px;
  305. height: 8px;
  306. background: #3C8DBC;
  307. border-radius: 3px;
  308. }
  309. }
  310. // 内容
  311. .headertable_nav{
  312. background-color: #fff;
  313. border-radius: 6px;
  314. padding: 23px;
  315. }
  316. }
  317. p{
  318. margin: 0;
  319. }
  320. </style>