index.vue 7.8 KB

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