FormHeadList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 查询区域 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="24">
  7. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  8. <a-form-item label="稽核名称">
  9. <j-input placeholder="请输入稽核名称" v-model="queryParam.tableName"></j-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  13. <a-form-item label="稽核描述">
  14. <j-input placeholder="请输入稽核描述" v-model="queryParam.tableTxt"></j-input>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  18. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  19. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  20. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  21. </span>
  22. </a-col>
  23. </a-row>
  24. </a-form>
  25. </div>
  26. <!-- 查询区域-END -->
  27. <!-- 操作按钮区域 begin -->
  28. <div class="table-operator">
  29. <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  30. <!-- <a-button @click="doCgformButton" type="primary" icon="highlight">自定义按钮</a-button>-->
  31. <!-- <a-button @click="doEnhanceJs" type="primary" icon="strikethrough">JS增强</a-button>-->
  32. <!-- <a-button @click="doEnhanceSql" type="primary" icon="filter">SQL增强</a-button>-->
  33. <!-- <a-button @click="doEnhanceJava" type="primary" icon="tool">JAVA增强</a-button>-->
  34. <!-- <a-button @click="importOnlineForm" type="primary" icon="database">导入数据库表</a-button>-->
  35. <a-button @click="goGenerateCode" type="primary" icon="database">代码生成</a-button>
  36. <!-- 高级查询区域 -->
  37. <a-dropdown v-if="selectedRowKeys.length > 0">
  38. <a-menu slot="overlay">
  39. <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
  40. </a-menu>
  41. <a-button style="margin-left: 8px">批量操作<a-icon type="down" /></a-button>
  42. </a-dropdown>
  43. </div>
  44. <!-- 操作按钮区域 end -->
  45. <!-- table区域 begin -->
  46. <div>
  47. <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
  48. <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
  49. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  50. </div>
  51. <a-table
  52. ref="table"
  53. size="middle"
  54. :scroll="{x:true}"
  55. bordered
  56. rowKey="id"
  57. :columns="columns"
  58. :dataSource="dataSource"
  59. :pagination="ipagination"
  60. :loading="loading"
  61. :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  62. class="j-table-force-nowrap"
  63. @change="handleTableChange">
  64. <template v-slot:action="text, record">
  65. <a @click="handleEdit(record)">编辑</a>
  66. <a-divider type="vertical"/>
  67. <a-dropdown>
  68. <a class="ant-dropdown-link">更多<a-icon type="down"/></a>
  69. <a-menu slot="overlay">
  70. <a-menu-item v-if="record.isDbSynch !== 'Y'">
  71. <a @click="openSyncModal(record.id)">同步数据库</a>
  72. </a-menu-item>
  73. <a-menu-item v-if="record.isDbSynch === 'Y' && record.tableType !== 3">
  74. <a @click="goPageOnline(record)">功能测试</a>
  75. </a-menu-item>
  76. <a-menu-item>
  77. <a @click="handleOnlineUrlShow(record)">配置地址</a>
  78. </a-menu-item>
  79. <!-- <a-menu-item>-->
  80. <!-- <a @click="goAuthConfig(record)">权限控制</a>-->
  81. <!-- </a-menu-item>-->
  82. <!-- <a-menu-item>-->
  83. <!-- <a @click="doAuthConfig(record)">角色授权</a>-->
  84. <!-- </a-menu-item>-->
  85. <!-- <a-menu-item>-->
  86. <!-- <a @click="copyConfig(record.id)">生成视图</a>-->
  87. <!-- </a-menu-item>-->
  88. <!-- <a-menu-item>-->
  89. <!-- <a @click="showMyCopyInfo(record)">视图管理</a>-->
  90. <!-- </a-menu-item>-->
  91. <!-- <a-menu-item>-->
  92. <!-- <a @click="handleDelete(record.id)">移除</a>-->
  93. <!-- </a-menu-item>-->
  94. </a-menu>
  95. </a-dropdown>
  96. </template>
  97. </a-table>
  98. </div>
  99. <!-- table区域 end -->
  100. <!-- 任务添加 -->
  101. <form-head-modal ref="modalForm" @ok="modalFormOk"></form-head-modal>
  102. <code-generator ref="cg"></code-generator>
  103. <a-modal :style="{top:'5%',height:'95%'}"
  104. :width="500"
  105. :height="300"
  106. title="同步数据库"
  107. :visible="syncModalVisible"
  108. @cancel="handleCancleDbSync">
  109. <template v-slot:footer>
  110. <a-button @click="handleCancleDbSync">关闭</a-button>
  111. <a-button type="primary" :loading="syncLoading" @click="handleDbSync">确定</a-button>
  112. </template>
  113. <a-radio-group v-model="synMethod">
  114. <a-radio :style="{display:'block',width:'30px',height: '30px'}" value="normal">普通同步(保留表数据)</a-radio>
  115. <a-radio :style="{display:'block',width:'30px',height: '30px'}" value="force">强制同步(删除表,重新生成)</a-radio>
  116. </a-radio-group>
  117. </a-modal>
  118. <a-modal :title="onlineUrlTitle"
  119. :visible="onlineUrlVisible"
  120. @cancel="handleOnlineUrlClose">
  121. <template v-slot:footer>
  122. <a-button @click="handleOnlineUrlClose">关闭</a-button>
  123. <a-button type="primary" class="copy-this-text" :data-clipboard-text="onlineUrl" @click="onCopyUrl">复制</a-button>
  124. </template>
  125. <p>{{onlineUrl}}</p>
  126. </a-modal>
  127. </a-card>
  128. </template>
  129. <script>
  130. import Clipboard from "clipboard";
  131. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  132. import FormHeadModal from './modules/FormHeadModal'
  133. import CodeGenerator from './modules/CodeGenerator'
  134. import {initDictOptions,filterDictText} from '@/components/dict/JDictSelectUtil'
  135. import {getAction, postAction,deleteAction} from '@/api/manage'
  136. export default {
  137. name: 'FormHeadList',
  138. mixins:[JeecgListMixin],
  139. inject:['closeCurrent'],
  140. components: {
  141. FormHeadModal,
  142. CodeGenerator,
  143. },
  144. data() {
  145. let self = this;
  146. return {
  147. description: '任务列表页面',
  148. columns2: [
  149. {
  150. title: '#',
  151. dataIndex: '',
  152. key:'rowIndex',
  153. width:60,
  154. align:"center",
  155. customRender:function (t,r,index) {
  156. return parseInt(index)+1;
  157. }
  158. },
  159. {
  160. title:'任务名称',
  161. align:"center",
  162. sorter: true,
  163. dataIndex: 'taskName',
  164. scopedSlots: { customRender: 'taskName' }
  165. },
  166. {
  167. title:'任务状态',
  168. align:"center",
  169. sorter: true,
  170. dataIndex: 'taskState_dictText'
  171. },
  172. {
  173. title:'任务开始时间',
  174. align:"center",
  175. sorter: true,
  176. dataIndex: 'taskStartTime'
  177. },
  178. {
  179. title:'任务结束时间',
  180. align:"center",
  181. sorter: true,
  182. dataIndex: 'taskEndTime'
  183. },
  184. {
  185. title: '操作',
  186. dataIndex: 'action',
  187. align:"center",
  188. fixed:"right",
  189. width:147,
  190. scopedSlots: { customRender: 'action' }
  191. }
  192. ],
  193. columns : [{
  194. title : "#",
  195. dataIndex : "",
  196. key : "rowIndex",
  197. width : 60,
  198. align : "center",
  199. customRender(obj, name, x) {
  200. return parseInt(x) + 1;
  201. }
  202. }, {
  203. title : "表类型",
  204. align : "center",
  205. sorter : true,
  206. dataIndex : "tableType",
  207. customRender(obj, record) {
  208. let result = filterDictText(self.tableTypeDictOptions, obj);
  209. if (record.isTree === "Y") {
  210. result += "(树)"
  211. }
  212. if(record.themeTemplate === "innerTable") {
  213. result += "(内嵌)"
  214. }else if(record.themeTemplate === "erp") {
  215. result += "(ERP)"
  216. }else if(record.themeTemplate === "tab") {
  217. result += "(TAB)"
  218. }
  219. if(record.tableType === 3) {
  220. result += (record.relationType === 0 ? "(一对多)" : "(一对一)")
  221. }
  222. return result;
  223. }
  224. }, {
  225. title : "表名",
  226. sorter : true,
  227. align : "center",
  228. dataIndex : "tableName"
  229. }, {
  230. title : "表描述",
  231. align : "center",
  232. dataIndex : "tableTxt"
  233. }, {
  234. title : "版本",
  235. align : "center",
  236. dataIndex : "tableVersion"
  237. }, {
  238. title : "同步状态",
  239. align : "center",
  240. sorter : true,
  241. dataIndex : "isDbSynch",
  242. scopedSlots : {
  243. customRender : "dbsync"
  244. }
  245. }, {
  246. title : "创建时间",
  247. align : "center",
  248. sorter : true,
  249. dataIndex : "createTime"
  250. }, {
  251. title : "操作",
  252. dataIndex : "action",
  253. align : "center",
  254. scopedSlots : {
  255. customRender : "action"
  256. }
  257. }],
  258. url : {
  259. list : "/online/form/head/list",
  260. delete : "/online/form/head/delete",
  261. deleteBatch : "/online/form/head/deleteBatch",
  262. removeRecord : "/online/form/head/removeRecord",
  263. copyOnline : "/online/form/head/copyOnline",
  264. doDbSynch : "/online/form/api/doDbSynch/",
  265. },
  266. autoSearch: true,
  267. tableTypeDictOptions : [],
  268. sexDictOptions : [],
  269. syncModalVisible : false,
  270. syncFormId : "",
  271. synMethod : "normal",
  272. syncLoading : false,
  273. onlineUrlTitle : "",
  274. onlineUrlVisible : false,
  275. onlineUrl : "",
  276. selectedRowKeys : [],
  277. selectedRows : [],
  278. confirmVisible : false,
  279. selectTableType : 1
  280. }
  281. },
  282. created : function() {
  283. let self = this;
  284. initDictOptions("cgform_table_type").then(function(newItem) {
  285. if (newItem.success) {
  286. self.tableTypeDictOptions = newItem.result;
  287. }
  288. });
  289. },
  290. methods: {
  291. doDbSynch(length) {
  292. let self = this;
  293. postAction(this.url.doDbSynch + length, {
  294. synMethod : "1"
  295. }).then(function(data) {
  296. if (data.success) {
  297. self.$message.success(data.message);
  298. self.loadData();
  299. } else {
  300. self.$message.warning(data.message);
  301. }
  302. });
  303. },
  304. handleCancleDbSync : function() {
  305. this.syncModalVisible = false;
  306. },
  307. handleDbSync() {
  308. let self = this;
  309. this.syncLoading = true;
  310. postAction(this.url.doDbSynch + this.syncFormId + "/" + this.synMethod).then(function(data) {
  311. self.syncModalVisible = false;
  312. self.syncLoading = false;
  313. if (data.success) {
  314. self.$message.success(data.message);
  315. self.loadData();
  316. } else {
  317. self.$message.warning(data.message);
  318. }
  319. });
  320. setTimeout(function() {
  321. if (self.syncLoading) {
  322. self.syncModalVisible = false;
  323. self.syncLoading = false;
  324. self.$message.success("网络延迟,已自动刷新!");
  325. self.loadData();
  326. }
  327. }, 10000);
  328. },
  329. openSyncModal(syncFormId) {
  330. this.syncModalVisible = true;
  331. this.syncLoading = false;
  332. this.syncFormId = syncFormId;
  333. },
  334. goPageOnline(record) {
  335. if ("erp" === record.themeTemplate) {
  336. this.$router.push({
  337. path : "/online/cgformErpList/" + record.id
  338. });
  339. } else {
  340. if ("innerTable" === record.themeTemplate) {
  341. this.$router.push({
  342. path : "/online/cgformInnerTableList/" + record.id
  343. });
  344. } else {
  345. if ("tab" === record.themeTemplate) {
  346. this.$router.push({
  347. path : "/online/cgformTabList/" + record.id
  348. });
  349. } else {
  350. if ("Y" == record.isTree) {
  351. this.$router.push({
  352. path : "/online/cgformTreeList/" + record.id
  353. });
  354. } else {
  355. this.$router.push({
  356. path : "/online/cgformList/" + record.id
  357. });
  358. }
  359. }
  360. }
  361. }
  362. },
  363. handleOnlineUrlClose : function() {
  364. this.onlineUrlTitle = "";
  365. this.onlineUrlVisible = false;
  366. },
  367. handleOnlineUrlShow(record) {
  368. if ("erp" === record.themeTemplate) {
  369. this.onlineUrl = "/online/cgformErpList/".concat(record.id);
  370. } else {
  371. if ("innerTable" === record.themeTemplate) {
  372. this.onlineUrl = "/online/cgformInnerTableList/".concat(record.id);
  373. } else {
  374. if ("tab" === record.themeTemplate) {
  375. this.onlineUrl = "/online/cgformTabList/".concat(record.id);
  376. } else {
  377. if ("Y" === record.isTree) {
  378. this.onlineUrl = "/online/cgformTreeList/".concat(record.id);
  379. } else {
  380. this.onlineUrl = "/online/cgformList/".concat(record.id);
  381. }
  382. }
  383. }
  384. }
  385. this.onlineUrlVisible = true;
  386. this.onlineUrlTitle = "菜单链接[" + record.tableTxt + "]";
  387. },
  388. handleRemoveRecord(newWayId) {
  389. let self = this;
  390. this.$confirm({
  391. title : "确认要移除此记录?",
  392. onOk : function() {
  393. deleteAction(self.url.removeRecord, {
  394. id : newWayId
  395. }).then(function(data) {
  396. if (data.success) {
  397. self.$message.success("移除成功");
  398. self.loadData();
  399. } else {
  400. self.$message.warning(data.message);
  401. }
  402. });
  403. },
  404. onCancel : function() {
  405. }
  406. });
  407. },
  408. doEnhanceJs : function() {
  409. if (this.selectedRowKeys && this.selectedRowKeys.length === 1) {
  410. this.$refs.ehjs.show(this.selectedRows[0]);
  411. } else {
  412. this.$message.warning("请先选中一条记录");
  413. }
  414. },
  415. doEnhanceSql : function() {
  416. if (this.selectedRowKeys && this.selectedRowKeys.length === 1) {
  417. this.$refs.ehsql.show(this.selectedRows[0]);
  418. } else {
  419. this.$message.warning("请先选中一条记录");
  420. }
  421. },
  422. doEnhanceJava : function() {
  423. if (this.selectedRowKeys && this.selectedRowKeys.length === 1) {
  424. this.$refs.ehjava.show(this.selectedRowKeys[0]);
  425. } else {
  426. this.$message.warning("请先选中一条记录");
  427. }
  428. },
  429. doCgformButton : function() {
  430. if (this.selectedRowKeys && this.selectedRowKeys.length === 1) {
  431. this.$refs.btnList.show(this.selectedRowKeys[0]);
  432. } else {
  433. this.$message.warning("请先选中一条记录");
  434. }
  435. },
  436. importOnlineForm : function() {
  437. this.$refs.transd2o.show();
  438. },
  439. transOk : function() {
  440. this.loadData();
  441. },
  442. goGenerateCode() {
  443. if (this.selectedRowKeys && this.selectedRowKeys.length === 1) {
  444. let row = this.selectedRows[0];
  445. if (row) {
  446. if (row.isDbSynch && row.isDbSynch !== "N") {
  447. if (row.tableType !== 3) {
  448. this.$refs.cg.show(this.selectedRowKeys[0]);
  449. } else {
  450. this.$message.warning("请选中该表对应的主表生成代码");
  451. }
  452. } else {
  453. this.$message.warning("请先同步数据库!");
  454. }
  455. } else {
  456. this.$message.warning("请选择当前页数据!");
  457. }
  458. } else {
  459. this.$message.warning("请先选中一条记录");
  460. }
  461. },
  462. onSelectChange : function(index, isSelected) {
  463. this.selectedRowKeys = index;
  464. this.selectedRows = isSelected;
  465. },
  466. onCopyUrl : function() {
  467. let self = this;
  468. let clipboard = new Clipboard(".copy-this-text");
  469. clipboard.on("success", function() {
  470. clipboard.destroy();
  471. self.$message.success("复制成功");
  472. self.handleOnlineUrlClose();
  473. });
  474. clipboard.on("error", function() {
  475. self.$message.error("该浏览器不支持自动复制");
  476. clipboard.destroy();
  477. });
  478. },
  479. showMyCopyInfo(checkoutId) {
  480. this.$router.push({
  481. path : "/online/copyform/" + checkoutId
  482. });
  483. },
  484. copyConfig(obj) {
  485. let that = this;
  486. postAction("".concat(this.url.copyOnline, "?code=").concat(obj)).then(result => {
  487. if (result.success) {
  488. that.$message.success("复制成功");
  489. that.loadData();
  490. } else {
  491. that.$message.error("复制失败>>" + result.message);
  492. }
  493. });
  494. },
  495. batchDeleteCust() {
  496. if (this.url.deleteBatch) {
  497. if (this.selectedRowKeys.length <= 0) {
  498. this.$message.warning("请选择一条记录!");
  499. } else {
  500. this.confirmVisible = true;
  501. }
  502. } else {
  503. this.$message.error("请设置url.deleteBatch属性!");
  504. }
  505. },
  506. doBatchDelete(checked) {
  507. let self = this;
  508. let removed = "";
  509. let layer_i = 0;
  510. for (; layer_i < this.selectedRowKeys.length; layer_i++) {
  511. removed = removed + (this.selectedRowKeys[layer_i] + ",");
  512. }
  513. let channel_collection = this;
  514. this.loading = true;
  515. deleteAction(channel_collection.url.deleteBatch, {
  516. ids : removed,
  517. flag : checked
  518. }).then(function(data) {
  519. if (data.success) {
  520. self.$message.success(data.message);
  521. self.loadData();
  522. self.onClearSelected();
  523. } else {
  524. self.$message.warning(data.message);
  525. }
  526. }).finally(function() {
  527. self.loading = false;
  528. self.confirmVisible = false;
  529. });
  530. },
  531. goAuthConfig(record) {
  532. this.selectTableType = record.tableType;
  533. this.$refs.authManager.show(record.id);
  534. },
  535. doAuthConfig(record) {
  536. this.selectTableType = record.tableType;
  537. this.$refs.authSetter.show(record.id);
  538. }
  539. }
  540. }
  541. </script>
  542. <style scoped>
  543. </style>