index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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" 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: ['1'],
  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. console.log(this.queryParams)
  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 == 'D'){
  147. //删除
  148. console.log(this.formy.id)
  149. this.handleDelete(this.deledlid)
  150. }else if(index == 'S'){
  151. //提交 保存
  152. this.formeanti.commitData = []
  153. this.formy.status = 1
  154. this.formeanti.commitData.push(this.formy)
  155. console.log(this.formeanti)
  156. this.antiSubmission()
  157. }else if(index == 'U'){
  158. //反提交 保存
  159. this.formeanti.commitData = []
  160. this.formy.status = 2
  161. this.formeanti.commitData.push(this.formy)
  162. console.log(this.formeanti)
  163. this.antiSubmission()
  164. }else if(index == 'M'){
  165. // 修改
  166. this.forme.fixedData = this.queryParams
  167. this.submitForm()
  168. }else if(index == 'A'){
  169. //新增
  170. this.forme.fixedData = this.queryParams
  171. this.submitForm()
  172. }
  173. console.log(this.forme)
  174. // this.getList();
  175. },
  176. getList() {
  177. },
  178. init() {
  179. getTableQuery(
  180. this.tableZbie
  181. ).then(res => {
  182. let data = res.data
  183. this.queryData = data
  184. console.log(this.queryData,567)
  185. })
  186. },
  187. tablsie(){
  188. console.log(1234)
  189. getQueryList(
  190. this.tabledeLise
  191. ).then(res => {
  192. let data = res.data
  193. this.taleLisst = data
  194. // console.log(this.queryData.queryList)
  195. })
  196. },
  197. handleChange(val) {
  198. console.log(val);
  199. },
  200. // 按钮点击
  201. delet(index){
  202. console.log(index)
  203. if(index == 'D'){
  204. this.handleDelete(this.formy.id)
  205. }
  206. },
  207. /** 新增 修改提交按钮 */
  208. submitForm: function() {
  209. addbjectSave(this.forme).then(response => {
  210. this.msgSuccess("保存成功");
  211. this.open = false;
  212. // this.getList();
  213. });
  214. },
  215. // 提交反提交
  216. antiSubmission(){
  217. if (this.formy.status == 1) {
  218. // 提交
  219. tableSubimt(this.formeanti).then(response => {
  220. this.msgSuccess("提交成功");
  221. // this.open = false;
  222. // this.getList();
  223. });
  224. } else if(this.formy.status == 2){
  225. // 反提交
  226. tableSubimtanit(this.formeanti).then(response => {
  227. this.msgSuccess("反提交成功");
  228. // this.open = false;
  229. // this.getList();
  230. });
  231. }
  232. },
  233. //删除
  234. handleDelete(index) {
  235. this.$confirm('是否确认删除名称为"' + index + '"的数据项?', "警告", {
  236. confirmButtonText: "确定",
  237. cancelButtonText: "取消",
  238. type: "warning"
  239. }).then(function() {
  240. return delMenutab(index);
  241. }).then(() => {
  242. // this.getList();
  243. this.msgSuccess("删除成功");
  244. })
  245. }
  246. },
  247. };
  248. </script>
  249. <style lang="scss">
  250. .table_header{
  251. .el-divider--horizontal{
  252. margin-top: 16px;
  253. }
  254. }
  255. .headertable_nav{
  256. .el-collapse-item__wrap{
  257. border-bottom: 0;
  258. }
  259. .el-collapse-item__header{
  260. border-bottom: 0;
  261. font-size: 15px;
  262. font-family: PingFang SC;
  263. font-weight: bold;
  264. color: #3C8DBC;
  265. line-height: 36px;
  266. }
  267. // .el-form-item__content{
  268. // width: 55%;
  269. // }
  270. .el-collapse{
  271. border-top: 0;
  272. }
  273. }
  274. </style>
  275. <style scoped lang="scss">
  276. .app-main{
  277. // background-color: #eef0ff !important;
  278. }
  279. .table_total{
  280. background-color: #eef0ff;
  281. height: 100%;
  282. padding: 20px;
  283. // 头部
  284. .table_header{
  285. background-color: #fff;
  286. border-radius: 6px;
  287. padding: 23px;
  288. margin-bottom: 20px;
  289. p{
  290. font-size: 15px;
  291. font-weight: bold;
  292. color: #3C8DBC;
  293. line-height: 36px;
  294. }
  295. p::before{
  296. content: "";
  297. display: block;
  298. width: 18px;
  299. height: 8px;
  300. background: #3C8DBC;
  301. border-radius: 3px;
  302. }
  303. }
  304. // 内容
  305. .headertable_nav{
  306. background-color: #fff;
  307. border-radius: 6px;
  308. padding: 23px;
  309. }
  310. }
  311. p{
  312. margin: 0;
  313. }
  314. </style>