index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template>
  2. <div class="bigBox">
  3. <div class="info">
  4. <p class="tt">基础信息</p>
  5. <div v-for="item in infoData[0]" :key="item.title">
  6. <span class="titlestyle">{{ item.value }}</span>
  7. <span
  8. class="infostyle"
  9. v-for="(val, index) in infoData[1]"
  10. :key="index"
  11. >{{ val[item.key] }}</span
  12. >
  13. </div>
  14. </div>
  15. <div class="tableBox">
  16. <div class="top">
  17. <div class="left" v-if="tableCount[0]">
  18. <p>{{ tableCount[0].statisticTitle }}</p>
  19. <i>{{ tableCount[0].result }}</i>
  20. </div>
  21. <div class="right">
  22. <p>是否外协</p>
  23. <el-checkbox v-model="checked"></el-checkbox>
  24. </div>
  25. </div>
  26. <!-- 按钮组 -->
  27. <el-button-group>
  28. <el-button v-for="(item, index) in controlBtnArr" :key="index">
  29. <template>
  30. <span @click="clickHandler(item, row)"
  31. ><svg-icon
  32. v-if="item.btnIcon"
  33. class="pre-icon"
  34. slot="prefix"
  35. :icon-class="item.btnIcon"
  36. />{{ item.btnName }}</span
  37. >
  38. </template>
  39. </el-button>
  40. </el-button-group>
  41. <el-form ref="tableform" :model="tableDataForm">
  42. <el-table
  43. border
  44. :data="tableData[1].data"
  45. style="width: 100%; margin-bottom: 20px"
  46. >
  47. <el-table-column
  48. v-for="item in tableData[0].column"
  49. :prop="item.key"
  50. :label="item.value"
  51. :key="item.value"
  52. width="180"
  53. >
  54. <template slot-scope="scope">
  55. <el-input
  56. :v-if="scope.row[item.key]"
  57. v-model="scope.row[item.key]"
  58. ></el-input>
  59. </template>
  60. </el-table-column>
  61. <el-table-column
  62. v-if="isShowExcuteCol"
  63. label="操作"
  64. align="center"
  65. class-name="small-padding fixed-width"
  66. >
  67. <template slot-scope="scope">
  68. <Menu
  69. :row="scope.row"
  70. v-for="btnObj in excuteBtnArr"
  71. :key="btnObj.id"
  72. :listAll="btnObj"
  73. @excuteHandler="excuteHandler"
  74. ></Menu>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <div>
  79. <b>统计信息 </b>
  80. <span v-for="(item, index) in subCount" :key="index"
  81. >{{ item.statisticTitle }}: {{ item.result }}</span
  82. >
  83. </div>
  84. <el-form-item>
  85. <el-button class="addBtn" icon="el-icon-plus" @click="addBtnHandler"
  86. >新增</el-button
  87. >
  88. <el-button
  89. class="saveBtn"
  90. icon="el-icon-document-checked"
  91. @click="saveBtnHandler"
  92. >保存</el-button
  93. >
  94. </el-form-item>
  95. </el-form>
  96. <div></div>
  97. </div>
  98. </div>
  99. </template>
  100. <script>
  101. import { dragGroupTableInfo } from "@/api/relateTable/index";
  102. import {
  103. btnCommonApi,
  104. dragTableInfo,
  105. unionListTableData,
  106. } from "@/api/tablelist/commonTable";
  107. import { camelCase } from "@/utils";
  108. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  109. import {
  110. getProcessPopupTableInfo,
  111. getProcessPopupTableList,
  112. } from "@/api/dragform/form"; //新的弹窗数据请求
  113. export default {
  114. components: { Menu },
  115. data() {
  116. return {
  117. // 基础信息行数据
  118. infoData: [],
  119. listInfo: {},
  120. // 是否外协
  121. checked: false,
  122. tableData: [],
  123. // 动态增加表格数据
  124. editData: [],
  125. tableDataForm: {},
  126. tableLists: [],
  127. queryParams: {
  128. pageNum: 1, // 第几页
  129. pageSize: 10, // 每页大小
  130. orderByColumn: "", // 根据某列排序
  131. isAsc: "", // desc(降序)或 asc(升序)
  132. // 基本查询参数
  133. basicMap: {
  134. tableName: "drag_form",
  135. },
  136. // 当前表字段筛选参数
  137. queryMap: {
  138. // 当前查询基本参数
  139. // ... key : value 当前页面的筛选条件
  140. // 超级查询的唯一值
  141. queryCriteriaValue: "",
  142. // tableCondition: ''
  143. },
  144. },
  145. columns: [],
  146. // 排序方式 默认降序
  147. sortOrder: true,
  148. tableName: "",
  149. // 当前模版信息
  150. templateInfo: {},
  151. queryFromWhere: "",
  152. condition: [],
  153. // 当前点击按钮的数据
  154. currentBtnData: {},
  155. // 操作列 按钮数据
  156. excuteBtnArr: [],
  157. // 新增保存的数据
  158. addListData: [],
  159. controlBtnArr: [],
  160. };
  161. },
  162. props: ["groupKey", "rowobj", "tableCount", "subCount", "subTableName"],
  163. computed: {
  164. isShowExcuteCol() {
  165. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  166. },
  167. },
  168. methods: {
  169. // 新增
  170. addBtnHandler() {
  171. let obj = {
  172. // id:'',
  173. };
  174. this.addListData.push(obj);
  175. this.tableData[1].data.push(obj);
  176. },
  177. // 保存
  178. saveBtnHandler() {
  179. console.log(this.addListData);
  180. let data = {
  181. addListMap: this.addListData,
  182. basicMap: {
  183. btnType: 10,
  184. tableName: this.subTableName,
  185. visible: true,
  186. },
  187. commMap: {},
  188. conditionMap: {},
  189. };
  190. btnCommonApi(data).then((res) => {
  191. console.log("保存", res);
  192. });
  193. },
  194. // 获取弹窗信息
  195. async getLists(payload) {
  196. // let res = await dragGroupTableInfo({ queryMap: { groupKey: groupKey } });
  197. let resTableInfo = await getProcessPopupTableInfo({ queryMap: payload });
  198. let resTableData = await getProcessPopupTableList({ queryMap: payload });
  199. // 获取表格tablekey 和 sort
  200. console.log(resTableData);
  201. this.tableLists = JSON.parse(res.msg);
  202. this.tableLists.forEach(async (item) => {
  203. // 基础信息
  204. if (item.sort == 0) {
  205. const res = await dragTableInfo({
  206. queryMap: { tableKey: item.tableKey },
  207. });
  208. this.getTableHandle(res, item.sort).then((result) => {
  209. console.log("result:", result);
  210. this.infoData.push(result);
  211. this.$set(this.infoData);
  212. });
  213. //表格数据
  214. } else if (item.sort == 1) {
  215. const res = await dragTableInfo({
  216. queryMap: { tableKey: item.tableKey },
  217. });
  218. this.excuteBtnArr = res.data.resultMap.button;
  219. this.getTableHandle(res, item.sort).then((result) => {
  220. // 表头数据
  221. this.tableData.push({
  222. column: result,
  223. });
  224. });
  225. // 统计状态 和 按钮
  226. } else if (item.sort == 2) {
  227. const res = await dragTableInfo({
  228. queryMap: { tableKey: item.tableKey },
  229. });
  230. // 按钮
  231. this.controlBtnArr = res.data.resultMap.button[0];
  232. this.controlBtnArr = this.controlBtnArr.children;
  233. }
  234. });
  235. },
  236. // 获取基础信息 表头数据
  237. async getTableHandle(res, sort) {
  238. this.columns = [];
  239. // 得到当前模版信息 --- sql columns queryWhere
  240. this.templateInfo = res.data.resultMap;
  241. // console.log(res.data.resultMap.querySql);
  242. this.queryParams.orderByColumn =
  243. res.data.resultMap.querySql.orderByColumn;
  244. this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
  245. // 根据拖拽时设置当前列表排列顺序
  246. this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
  247. this.tableName = this.templateInfo.template.dtTableName;
  248. // 得到查询条件
  249. this.queryFromWhere = res.data.resultMap.where;
  250. // 得到当前列表信息
  251. this.columns = this.columnsHandler(
  252. JSON.parse(this.templateInfo.template.dtColumnName)
  253. );
  254. if (this.templateInfo) {
  255. this.tableCondition = this.templateInfo.querySql.tableCondition;
  256. this.tableCondition = this.tableCondition.split("AND");
  257. // console.log(this.tableCondition);
  258. this.condition = [];
  259. // 调用查询需要携带当前table的唯一标识
  260. this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
  261. this.queryParams.orderByColumn = camelCase(
  262. this.queryParams.orderByColumn || ""
  263. );
  264. // 根据sql语句查询当前表数据
  265. let k;
  266. this.tableCondition.forEach((item, i) => {
  267. let val = item.split("=");
  268. if (i !== 0) {
  269. k = val[0].split(".");
  270. let str = k[0].trim() + "." + k[1];
  271. this.condition.push({
  272. key: k[0].trim(),
  273. value: k[1],
  274. });
  275. }
  276. });
  277. this.getDataHandler(this.tableCondition[1]).then((res) => {
  278. // console.log(res);
  279. if (sort == 0) {
  280. this.infoData.push(res);
  281. // this.$set(this.infoData)
  282. } else if (sort == 1) {
  283. this.tableData.push({
  284. data: res,
  285. });
  286. // this.$set(this.tableData)
  287. }
  288. });
  289. // console.log('columns', this.columns);
  290. return this.columns;
  291. }
  292. },
  293. // 获取表数据
  294. async getDataHandler(contion) {
  295. let con = contion.split("=");
  296. let key = con[1].trim();
  297. let value = key.split(".");
  298. // 拼接请求数据依赖条件
  299. this.queryParams.queryMap[key] = "'" + this.rowobj[value[1]] + "'";
  300. let tableLists = await unionListTableData(this.queryParams);
  301. if (tableLists.code == 200) {
  302. this.tableList = [];
  303. tableLists.rows.forEach((item) => {
  304. this.tableList.push(item.resultMap);
  305. });
  306. // 驼峰转换
  307. this.tableList = this.tableList.map((item) => {
  308. let kv = {};
  309. for (let itemKey in item) {
  310. kv[camelCase(itemKey)] = item[itemKey];
  311. }
  312. return kv;
  313. });
  314. return this.tableList;
  315. }
  316. },
  317. // 处理列表信息
  318. columnsHandler(columns) {
  319. let resArr = [];
  320. columns.forEach((item) => {
  321. for (const key in item) {
  322. let tempObj = {};
  323. tempObj.key = camelCase(key);
  324. tempObj.value = item[key];
  325. resArr.push(tempObj);
  326. }
  327. });
  328. return resArr;
  329. },
  330. // 操作列回调
  331. excuteHandler(btnData, row) {
  332. let { btnType, btnParams } = btnData;
  333. this.currentBtnData = btnData;
  334. switch (
  335. btnType //3:内链 6:目录 7:外链 8:修改 9:删除
  336. ) {
  337. case "3":
  338. this.routerHandler(btnData, btnType);
  339. break;
  340. case "7":
  341. this.routerHandler(btnData, btnType);
  342. break;
  343. case "8":
  344. this.handleUpdate(row, btnData);
  345. break;
  346. case "9":
  347. this.handleDelete(row, btnData);
  348. break;
  349. default:
  350. break;
  351. }
  352. },
  353. // 内链页面跳转
  354. routerHandler(btnData, type) {
  355. let link = btnData.btnParams;
  356. if (type == "3") {
  357. this.$router.push(link);
  358. } else {
  359. window.open("http://" + link, "_blank");
  360. }
  361. },
  362. // 删除
  363. handleDelete(row, btnData) {},
  364. // 修改
  365. handleUpdate(row, btnData) {
  366. console.log(row);
  367. },
  368. // 按钮组点击
  369. clickHandler(item, row) {},
  370. },
  371. mounted() {
  372. // this.getLists()
  373. },
  374. };
  375. </script>
  376. <style scoped lang="scss">
  377. .bigBox {
  378. margin: auto;
  379. display: flex;
  380. ::v-deep .info[data-v-32a636fc] {
  381. min-width: 200px !important;
  382. }
  383. .info {
  384. margin-right: 60px;
  385. .tt {
  386. font-size: 18px;
  387. font-weight: 700;
  388. }
  389. span {
  390. display: inline-block;
  391. }
  392. .titlestyle {
  393. background-color: #34bfa3;
  394. /* width: 50px; */
  395. display: inline-block;
  396. /* height: 25px; */
  397. line-height: 1;
  398. padding: 5px;
  399. margin-bottom: 20px;
  400. margin-right: 5px;
  401. text-align: center;
  402. color: white;
  403. border-radius: 20px;
  404. }
  405. .infostyle {
  406. background-color: #ebedf2;
  407. color: #e84e95;
  408. }
  409. }
  410. .tableBox {
  411. .svg-icon[data-v-c8a70580] {
  412. margin-right: 5px;
  413. }
  414. min-width: 300px;
  415. .addTable {
  416. margin: 0px 0px 20px 0px;
  417. }
  418. .titleitem {
  419. text-align: center;
  420. font-size: 20px;
  421. margin-top: 20px;
  422. }
  423. .addBtn {
  424. background-color: #0275d8;
  425. color: white;
  426. }
  427. .saveBtn {
  428. background-color: #34bfa3;
  429. color: white;
  430. }
  431. .top {
  432. padding: 20px;
  433. box-sizing: border-box;
  434. background-color: #53b0f8;
  435. display: flex;
  436. justify-content: space-around;
  437. color: white;
  438. flex: 1;
  439. /* width: 90%; */
  440. }
  441. .el-button-group {
  442. width: 100%;
  443. margin: 10px;
  444. background-color: white;
  445. .el-button:first-child {
  446. color: blue;
  447. border: 1px solid blue;
  448. }
  449. .el-button:nth-child(2) {
  450. color: palevioletred;
  451. border: 1px solid palevioletred;
  452. }
  453. .el-button:nth-child(3) {
  454. color: green;
  455. border: 1px solid green;
  456. }
  457. .el-button:last-child {
  458. color: burlywood;
  459. border: 1px solid burlywood;
  460. }
  461. .custom {
  462. width: 120px;
  463. }
  464. }
  465. }
  466. }
  467. </style>