index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. <template>
  2. <div class="tabForm">
  3. <div class="tabForm_header">
  4. <div class="imge_tab"><img src="../../../assets/images/pic_sy_ytj.png" alt="" v-if="imgShoew"></div>
  5. <div class="table_headerBtun" v-if="queryData.buttonList">
  6. <el-button type="primary" size="small" plain @click="handleQuery(item)" v-for="(item,index) in queryData.buttonList.split('')" :key="index">{{item | btnConversion}}</el-button>
  7. <el-button type="primary" size="small" plain @click="handleQuery('sx')">刷新</el-button>
  8. <el-button type="primary" size="small" plain @click="handleQuery('fh')">返回</el-button>
  9. </div>
  10. </div>
  11. <!-- 内容 -->
  12. <div class="table_nav">
  13. <el-collapse v-model="activeNames">
  14. <el-form :model="queryParams" :rules="queryData.rules" ref="queryForm" :inline="true" label-width="120px">
  15. <el-collapse-item :title="item.columnComment" :name="index" v-for="(item,index) in queryData.showData" :key="index" class="eitde">
  16. <el-row :gutter="0">
  17. <el-col :span="24" :key="index">
  18. <dynamic-forms @modelFn="modelFn" :ref="items.columnName" :config="queryParams" @inputs = "changeFn" :formConfig="items" v-for="(items,indexs) in item.hrChildren" :key='indexs' />
  19. </el-col>
  20. </el-row>
  21. </el-collapse-item>
  22. </el-form>
  23. <!-- 列表 -->
  24. <el-collapse-item :title="title" name="index" class="eitde" v-if="tabShoes">
  25. <div class="ppl">
  26. <p v-for="(item,index) in tabldie" :key="index" @click="enditTab(index)">
  27. <img src="../../../assets/images/icon_tbtab_normal.png" alt="" class="index_headerImg" v-if="numtab !== index">
  28. <img src="../../../assets/images/icon_tbtab_selected.png" alt="" class="index_headerImg" v-if="numtab == index">
  29. <span :class="[index == numtab ? 'span' : '']">{{item.tableComment}}</span>
  30. </p>
  31. </div>
  32. <el-divider></el-divider>
  33. <el-form :model="queryParamstwoi" ref="queryForm" :inline="true" >
  34. <dynamic-forms :ref="item.columnName" :config="queryParamstwoi" @inputs="changeFn" :formConfig="item" v-for="(item,index) in queryDatatao.showData"
  35. :key='index' />
  36. <el-form-item>
  37. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryiu">搜索</el-button>
  38. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  39. </el-form-item>
  40. </el-form>
  41. <el-table stripe v-loading="loading" :data="postList.rows" @selection-change="handleSelectionChange">
  42. <template v-for="(item, index) in postList.tableHeadList">
  43. <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" :key="index">
  44. <template slot-scope="scope">
  45. <img class="img_icon" v-if="item.htmlType=='imageUpload'&& scope.row[scope.column.property]" @click="imgBtn(JSON.parse(scope.row[scope.column.property])[0].url)" :src="JSON.parse(scope.row[scope.column.property])[0].url" alt="">
  46. <span v-else>{{ scope.row[scope.column.property] }}</span>
  47. </template>
  48. </el-table-column>
  49. </template>
  50. <!-- <el-table-column :label="item.columnComment" align="center" :prop="item.columnName" v-for="(item,index) in postList.tableHeadList" :key="index" /> -->
  51. </el-table>
  52. <div class="index_haderPagin">
  53. <pagination
  54. v-show="total>0"
  55. :total="total"
  56. :page.sync="queryParamslist.pageNo"
  57. :limit.sync="queryParamslist.pageSize"
  58. @pagination="foremliseju"
  59. />
  60. <!-- <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="currentPage3"
  61. :page-size="queryParamslist.pageSize" layout="prev, pager, next, jumper" v-show="total>0"
  62. :total="total" @pagination="foremliseju">
  63. </el-pagination> -->
  64. </div>
  65. </el-collapse-item>
  66. </el-collapse>
  67. <BigPicture ref="BigPicture" :urls="pir_imgs"></BigPicture>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import {
  73. getTableQuery,
  74. getObject,
  75. geteditindeTab,
  76. listIndex,
  77. delMenutabform,
  78. tableSubimt, tableSubimtanit, addbjectSave
  79. } from '@/api/system/form.js'
  80. export default {
  81. name: "index",
  82. data() {
  83. return {
  84. pir_imgs: '', // 图片链接
  85. num: 0,
  86. // 总条数
  87. total: 0,
  88. loading:true,
  89. tabList: {},
  90. currentPage3: 0,
  91. activeNames: [1],
  92. title: '列表',
  93. objParams: {
  94. table: 'obj_test',
  95. fixedData: {
  96. id: -1
  97. },
  98. isUi:true
  99. },
  100. objParamstue:{
  101. table: 'obj_test',
  102. fixedData: {
  103. id: -1
  104. },
  105. isUi:false
  106. },
  107. queryData: {},
  108. queryDatatao:{},
  109. // 查询参数
  110. queryParams: {
  111. dictName: undefined,
  112. dictType: undefined,
  113. status: undefined
  114. },
  115. queryParamstwoi:{
  116. dictName: undefined,
  117. dictType: undefined,
  118. status: undefined
  119. },
  120. queryParamslist: {
  121. pageNo: 1,
  122. pageSize: 10,
  123. orderBy:'create_time desc',
  124. table: '',
  125. fixedData:{
  126. condition:{}
  127. }
  128. },
  129. labletit: '查询参数1233',
  130. surlable: '实际数据库表',
  131. postList: {},
  132. numtab: 0,
  133. tabldie:[],
  134. xidugje: '',
  135. tabShoes:false,//tab 显示隐藏
  136. tableZbietabg:{
  137. table:'sys_user'
  138. },
  139. forme:{
  140. table:'',
  141. fixedData:{}
  142. },
  143. formeanti:{
  144. table:'',
  145. commitData:[],
  146. },
  147. formy:{
  148. id:0,
  149. status:1
  150. },
  151. // 删除参数
  152. deledlid:{
  153. table:'',
  154. idList:[]
  155. },
  156. imgShoew:false
  157. };
  158. },
  159. filters:{
  160. btnConversion(val) {
  161. switch(val){
  162. case 'A':
  163. return '保存';
  164. case 'M':
  165. return '修改';
  166. case 'D':
  167. return '删除';
  168. case 'Q':
  169. return '查询';
  170. case 'S':
  171. return '提交';
  172. case 'U':
  173. return '反提交';
  174. case 'I':
  175. return '导入';
  176. case 'E':
  177. return '导出';
  178. }
  179. }
  180. },
  181. mounted() {
  182. this.formeanti.table = this.$route.query.tables
  183. this.forme.table = this.$route.query.tables
  184. this.forme.objId = this.$route.query.id
  185. this.formy.id = this.$route.query.id
  186. this.tableZbietabg.table = this.$route.query.tables
  187. // this.objParams.table = this.$route.query.tables
  188. this.objParams.fixedData.id = this.$route.query.id
  189. this.deledlid.table = this.$route.query.tables
  190. this.deledlid.idList.push(this.$route.query.id)
  191. this.queryParamslist.table = this.$route.query.tables
  192. this.objParamstue.fixedData.id = this.$route.query.id
  193. this.init()
  194. this.edingelsietab()
  195. },
  196. methods: {
  197. imgBtn(url) {
  198. this.pir_imgs = url
  199. this.$refs.BigPicture.hidden.status = true
  200. },
  201. modelFn(obj, cont) {
  202. this.$set(this.queryParams,obj,cont)
  203. },
  204. handleCurrentChange() {
  205. },
  206. handleSizeChange() {
  207. },
  208. handleSelectionChange() {
  209. },
  210. headerBtn(item) {
  211. switch(item) {
  212. case 'A': {
  213. return
  214. }
  215. case 'M': {
  216. return
  217. }
  218. case 'D': {
  219. return
  220. }
  221. case 'Q': {
  222. return
  223. }
  224. case 'S': {
  225. return
  226. }
  227. case 'U': {
  228. return
  229. }
  230. case 'E': {
  231. return
  232. }
  233. }
  234. },
  235. init() {
  236. getObject(this.objParams).then(res => {
  237. console.log(res)
  238. let data = res.data
  239. this.queryData = data
  240. // 图片的显示隐藏
  241. if(this.queryData.showData.length !==0){
  242. this.queryData.showData.filter(route => {
  243. if(route.hrChildren.length !== 0){
  244. if(route.hrChildren[0].readonly !== null){
  245. if(route.hrChildren[0].readonly == true){
  246. this.imgShoew = true
  247. }else{
  248. this.imgShoew = false
  249. }
  250. }
  251. }
  252. })
  253. }
  254. if(this.xidugje == 'sx'){
  255. if(res.code == 200){
  256. this.msgSuccess("操作成功");
  257. }
  258. }
  259. })
  260. },
  261. // tab数据
  262. edingelsietab(){
  263. geteditindeTab(this.tableZbietabg).then(response => {
  264. if(response.data.ref.length !==0){
  265. this.tabldie = response.data.ref
  266. this.queryParamslist.table = this.tabldie[0].tableName
  267. this.objParamstue.table = this.tabldie[0].tableName
  268. this.tabShoes = true
  269. this.foremliseju()
  270. this.foremlisejuque()
  271. }else{
  272. this.tabShoes = false
  273. }
  274. // this.msgSuccess("反提交成功");
  275. // this.open = false;
  276. // this.getList();
  277. });
  278. },
  279. // 列表数据
  280. foremliseju(){
  281. listIndex(this.queryParamslist).then(res => {
  282. console.log(res)
  283. let data = res.data
  284. this.postList = data
  285. this.loading = false
  286. this.total = res.data.total - 0
  287. console.log(this.total)
  288. console.log(this.postList,567)
  289. })
  290. },
  291. // 列表查询接口
  292. foremlisejuque(){
  293. getObject(this.objParamstue).then(res => {
  294. console.log(res)
  295. this.queryDatatao = res.data
  296. // let data = res.data
  297. // this.queryData = data
  298. // 图片的显示隐藏
  299. })
  300. },
  301. // tab点击
  302. tabSbu(index) {
  303. this.num = index
  304. },
  305. enditTab(index) {
  306. this.numtab = index
  307. this.queryParamslist.table = this.tabldie[index].tableName
  308. this.foremliseju()
  309. },
  310. changeFn(obj) {
  311. for(let key in obj){
  312. this.queryParams[key] = obj[key]
  313. }
  314. },
  315. resetQuery() {
  316. },
  317. /** 搜索按钮操作 */
  318. handleQuery(index) {
  319. if(index == 'fs'){
  320. this.$router.go(-1)
  321. return
  322. }else if(index == 'sx'){
  323. this.xidugje = 'sx'
  324. this.init()
  325. this.edingelsietab()
  326. return
  327. }
  328. for(let item of this.queryData.showData){
  329. for(var i = 0 ; i < item.hrChildren.length ; i++){
  330. if(item.hrChildren[i].htmlType == 'checkbox'){
  331. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config
  332. }else if(item.hrChildren[i].htmlType == 'imageUpload' || item.hrChildren[i].htmlType == 'fileUpload'){
  333. if(this.$refs[item.hrChildren[i].columnName][0].config.length){
  334. this.queryParams[item.hrChildren[i].columnName] = JSON.stringify(this.$refs[item.hrChildren[i].columnName][0].config)
  335. }
  336. } else{
  337. this.queryParams[item.hrChildren[i].columnName] = this.$refs[item.hrChildren[i].columnName][0].config[item.hrChildren[i].columnName]
  338. }
  339. }
  340. }
  341. if(index == 'D'){
  342. //删除
  343. this.handleDelete(this.deledlid)
  344. }else if(index == 'S'){
  345. //提交 保存
  346. // this.formeanti.table = 'obj_test'
  347. this.formeanti.commitData = []
  348. this.formy.status = 1
  349. // this.formy.id = 0
  350. this.formeanti.commitData.push(this.formy)
  351. console.log(this.formeanti)
  352. this.antiSubmission()
  353. }else if(index == 'U'){
  354. //反提交 保存
  355. // this.formeanti.table = 'obj_test'
  356. this.formeanti.commitData = []
  357. this.formy.status = 2
  358. // this.formy.id = 0
  359. this.formeanti.commitData.push(this.formy)
  360. console.log(this.formeanti)
  361. this.antiSubmission()
  362. }else if(index == 'M'){
  363. // 修改
  364. // this.forme.table = 'obj_test'
  365. // this.forme.objId = 1
  366. this.forme.fixedData = this.queryParams
  367. this.submitForm()
  368. }else if(index == 'A'){
  369. //新增
  370. // this.forme.table = 'obj_test'
  371. // this.forme.objId = -1
  372. // this.msgInfo('暂不支持新增')
  373. // return
  374. this.forme.fixedData = this.queryParams
  375. this.submitForm()
  376. }
  377. console.log(this.forme)
  378. // this.getList();
  379. },
  380. // 搜索列表
  381. handleQueryiu(){
  382. for(let item of this.queryDatatao.showData){
  383. // for(var i = 0 ; i < item.hrChildren.length ; i++){
  384. if(item.htmlType == 'checkbox'){
  385. this.queryParamstwoi[item.columnName] = this.$refs[item.columnName][0].config
  386. }else if(item.htmlType == 'imageUpload' || item.htmlType == 'fileUpload'){
  387. this.queryParamstwoi[item.columnName] = JSON.stringify(this.$refs[item.columnName][0].config)
  388. } else{
  389. this.queryParamstwoi[item.columnName] = this.$refs[item.columnName][0].config[item.columnName]
  390. }
  391. // }
  392. }
  393. for(var items in this.queryParamstwoi){
  394. if(this.queryParamstwoi[items] == ''){
  395. this.queryParamstwoi[items] = undefined
  396. }
  397. }
  398. this.queryParamslist.fixedData.condition = this.queryParamstwoi
  399. this.foremliseju()
  400. console.log(this.queryParamstwoi)
  401. },
  402. /** 新增 修改提交按钮 */
  403. submitForm: function() {
  404. this.$refs["queryForm"].validate(valid => {
  405. if (valid) {
  406. addbjectSave(this.forme).then(response => {
  407. this.msgSuccess("保存成功");
  408. this.open = false;
  409. this.$router.go(-1)
  410. // this.getList();
  411. });
  412. }
  413. });
  414. },
  415. // 提交反提交
  416. antiSubmission(){
  417. this.$refs["queryForm"].validate(valid => {
  418. if (valid) {
  419. if (this.formy.status == 1) {
  420. // 提交
  421. tableSubimt(this.formeanti).then(response => {
  422. this.msgSuccess("提交成功");
  423. this.$router.go(-1)
  424. // this.open = false;
  425. // this.getList();
  426. });
  427. } else if(this.formy.status == 2){
  428. // 反提交
  429. tableSubimtanit(this.formeanti).then(response => {
  430. this.msgSuccess("反提交成功");
  431. this.$router.go(-1)
  432. // this.open = false;
  433. // this.getList();
  434. });
  435. }
  436. }
  437. });
  438. },
  439. //删除
  440. handleDelete(index) {
  441. this.$confirm('是否确认删除', "警告", {
  442. confirmButtonText: "确定",
  443. cancelButtonText: "取消",
  444. type: "warning"
  445. }).then(function() {
  446. return delMenutabform(index);
  447. }).then(() => {
  448. // this.getList();
  449. this.msgSuccess("删除成功");
  450. this.$router.go(-1)
  451. })
  452. }
  453. },
  454. };
  455. </script>
  456. <style lang="scss">
  457. .tabForm {
  458. .el-collapse-item__content {
  459. padding: 0;
  460. }
  461. .table_nav {
  462. .el-collapse-item__wrap {
  463. border-bottom: 0;
  464. }
  465. .el-collapse-item__header {
  466. border-bottom: 0;
  467. font-size: 15px;
  468. font-family: PingFang SC;
  469. font-weight: bold;
  470. color: #3C8DBC;
  471. line-height: 36px;
  472. }
  473. // .el-form-item__content {
  474. // width: 55%;
  475. // }
  476. .el-collapse {
  477. border-top: 0;
  478. border: 0;
  479. }
  480. .el-divider--horizontal {
  481. margin-top: 0;
  482. }
  483. .eitde {
  484. background-color: #fff;
  485. border-radius: 6px;
  486. padding: 23px;
  487. margin-bottom: 20px;
  488. }
  489. }
  490. }
  491. </style>
  492. <style scoped lang="scss">
  493. .tabForm {
  494. background-color: #eef0ff;
  495. height: 100%;
  496. padding: 20px;
  497. p {
  498. margin: 0;
  499. }
  500. // 头部
  501. .tabForm_header {
  502. background-color: #fff;
  503. border-radius: 6px;
  504. padding: 23px;
  505. margin-bottom: 20px;
  506. position: relative;
  507. }
  508. // 内容
  509. .table_nav {
  510. // background-color: #fff;
  511. // border-radius: 6px;
  512. // padding: 23px;
  513. .ppl {
  514. display: flex;
  515. height: 38px;
  516. p {
  517. position: relative;
  518. width: 113px;
  519. height: 38px;
  520. img {
  521. position: absolute;
  522. top: 0;
  523. left: 0;
  524. width: 100%;
  525. height: 100%;
  526. // z-index: -1;
  527. }
  528. span {
  529. width: 100%;
  530. position: absolute;
  531. top: 0;
  532. left: 0;
  533. // transform: translate(-50%);
  534. text-align: center;
  535. line-height: 38px;
  536. font-size: 15px;
  537. font-family: PingFang SC;
  538. font-weight: bold;
  539. color: #aaa;
  540. }
  541. .span {
  542. color: #3C8DBC;
  543. }
  544. }
  545. }
  546. }
  547. }
  548. // tab
  549. .index_headetab {
  550. display: flex;
  551. border-bottom: 1px solid #E5E5E5;
  552. height: 53px;
  553. // padding-top: 20px;
  554. padding-bottom: 10px;
  555. margin-bottom: 20px !important;
  556. span {
  557. width: 70px;
  558. text-align: center;
  559. line-height: 53px;
  560. height: 53px;
  561. font-size: 15px;
  562. font-family: PingFang SC;
  563. font-weight: bold;
  564. color: #666;
  565. position: relative;
  566. // flex: 1;
  567. // border-bottom: ;
  568. }
  569. .span {
  570. content: '';
  571. display: block;
  572. width: 18px;
  573. height: 8px;
  574. border-radius: 3px;
  575. background-color: #3C8DBC;
  576. color: #3C8DBC !important;
  577. // position: absolute;
  578. // border-bottom: ;
  579. }
  580. .spanto {
  581. color: #3C8DBC;
  582. border-bottom: 3px solid #3C8DBC;
  583. }
  584. }
  585. .imge_tab{
  586. position: absolute;
  587. right: 0;
  588. top: 5px;
  589. }
  590. </style>