65f2da4fb13a607e441f7a20b055d65194219d7e.svn-base 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="">
  3. <j-modal
  4. width="80%"
  5. :title="title"
  6. :visible.sync="editModalVisible"
  7. :fullscreen.sync="fullscreen"
  8. :switch-fullscreen="switchFullscreen"
  9. @cancel="handleCancleDbSync"
  10. :destroyOnClose="true"
  11. >
  12. <template slot="footer">
  13. <a-button @click="handleCancleDbSync">
  14. 关闭
  15. </a-button>
  16. <a-button type="primary" :loading="syncLoading" @click="handleDbSync" >确定</a-button>
  17. </template>
  18. <div class="table-page-search-wrapper warp">
  19. <a-form-model layout="inline" ref="ruleForm" :model="formData" :rules="rules">
  20. <a-row :gutter="24">
  21. <a-col :xl="8" :lg="8" :md="8" :sm="24">
  22. <a-form-model-item label="组合报表名称" prop="templetName">
  23. <a-input v-model="formData.templetName" placeholder="请输入报表名称"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :xl="8" :lg="8" :md="8" :sm="24">
  27. <a-form-model-item label="组合报表编码" prop="templetCode">
  28. <a-input v-model="formData.templetCode" placeholder="请输入报表编码"/>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :xl="8" :lg="8" :md="8" :sm="24">
  32. <a-form-model-item label="组合报表风格" prop="templetStyle">
  33. <j-dict-select-tag v-model="formData.templetStyle" placeholder="请选择报表" dict-code="online_graph_display_template"/>
  34. </a-form-model-item>
  35. </a-col>
  36. </a-row>
  37. </a-form-model>
  38. <a-tabs defaultActiveKey="1">
  39. <a-tab-pane key="1" tab="图表配置">
  40. <!-- 操作按钮区域 -->
  41. <div class="table-operator">
  42. <a-button type="primary" icon="plus" @click="handleAddGraphRepoart">新增</a-button>
  43. <a-popconfirm v-if="selectedRowKeys.length" :title="'确定要删除这'+selectedRowKeys.length+'项吗?'" @confirm="() => handleRemoveGraphRepoart()">
  44. <a-button icon="minus" >删除</a-button>
  45. </a-popconfirm>
  46. </div>
  47. <a-table
  48. size="middle"
  49. bordered
  50. :rowKey="(record, index) => index"
  51. :columns="columns"
  52. :data-source="formData.diagramCombinationDetails"
  53. :pagination="false"
  54. :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  55. >
  56. <div slot="graphreportName" slot-scope="text, record ">
  57. <a-select
  58. v-model="record['graphreportCode']"
  59. :options="graphreportNames"
  60. allowClear
  61. style="margin: -5px 0"
  62. show-search
  63. :filter-option="filterOption"
  64. ></a-select>
  65. </div>
  66. <div slot="graphreportType" slot-scope="text, record">
  67. <a-select v-model="record['graphreportType']" >
  68. <a-select-option v-for="(item,i) in graphTypeDictOptions" :key="i" :value="item.value">{{item.text}}</a-select-option>
  69. </a-select>
  70. </div>
  71. <div slot="groupNum" slot-scope="text, record,index">
  72. <a-input
  73. type="number"
  74. style="margin: -5px 0"
  75. :value="text"
  76. v-model="record['groupNum']"
  77. @change="groupNumChange(record,index)"
  78. />
  79. </div>
  80. <div slot="groupTxt" slot-scope="text, record">
  81. <a-input
  82. style="margin: -5px 0"
  83. :value="text"
  84. v-model="record['groupTxt']"
  85. @change="combinationChange('groupTxt',record['groupTxt'],record['groupNum'])"
  86. />
  87. </div>
  88. <div slot="groupStyle" slot-scope="text, record">
  89. <a-select style="margin: -5px 0" @change="combinationChange('groupStyle',record['groupStyle'],record['groupNum'])" v-model="record['groupStyle']" allowClear>
  90. <a-select-option value="card">卡片</a-select-option>
  91. <a-select-option value="tab">标签页</a-select-option>
  92. <a-select-option value="grid">栅格</a-select-option>
  93. <a-select-option value="combination">组合</a-select-option>
  94. </a-select>
  95. </div>
  96. <div slot="isShow" slot-scope="text, record">
  97. <a-checkbox :checked="record['isShow']?true:false" @change="checkboxChange(record,'isShow')" style="margin: -5px 0" ></a-checkbox>
  98. </div>
  99. <div slot="templetGrid" slot-scope="text, record">
  100. <j-input-pop v-model="record['templetGrid']" @change="combinationChange('templetGrid',record['templetGrid'],record['groupNum'])" style="margin: -5px 0" ></j-input-pop>
  101. </div>
  102. <div slot="groupGrid" slot-scope="text, record">
  103. <j-input-pop v-model="record['groupGrid']" style="margin: -5px 0" ></j-input-pop>
  104. </div>
  105. <div slot="orderNum" slot-scope="text, record">
  106. <a-input
  107. type="number"
  108. style="margin: -5px 0"
  109. :value="text"
  110. v-model="record['orderNum']"
  111. />
  112. </div>
  113. </a-table>
  114. </a-tab-pane>
  115. <a-tab-pane key="2" tab="查询配置">
  116. <graphreport-query-config ref="graphreportQueryConfig" :dataSource="formData.diagramCombinationQueryConfigs"></graphreport-query-config>
  117. </a-tab-pane>
  118. </a-tabs>
  119. </div>
  120. </j-modal>
  121. </div>
  122. </template>
  123. <script>
  124. import JSelectMultiple from '@/components/jeecg/JSelectMultiple'
  125. import { postAction, putAction, getAction } from '@/api/manage'
  126. import { validateDuplicateValue } from '@/utils/util'
  127. import JInputPop from '@/components/jeecg/minipop/JInputPop'
  128. import GraphreportQueryConfig from '../components/GraphreportQueryConfig'
  129. import { CHART_LIST } from '../utils/Utils'
  130. export default {
  131. name: 'onlGraphreportTempletModal',
  132. components: {
  133. JSelectMultiple,
  134. JInputPop,
  135. GraphreportQueryConfig
  136. },
  137. computed: {
  138. yaxisField: {// y轴字段双向绑定转换
  139. get: function() {
  140. return this.formData.yaxisField ? this.formData.yaxisField.split(',') : []
  141. },
  142. set: function(value) {
  143. this.formData.yaxisField = value.join(',')
  144. }
  145. }
  146. },
  147. data() {
  148. return {
  149. editModalVisible: false,
  150. title: '编辑',
  151. syncLoading: false,
  152. fullscreen: true,
  153. switchFullscreen: true,
  154. graphreportNames: [], // 自定义图表集合
  155. selectedRowKeys: [],
  156. columns: [
  157. {
  158. title: '#',
  159. dataIndex: '',
  160. key: 'rowIndex',
  161. width: '4%',
  162. align: 'center',
  163. customRender: function(t, r, index) {
  164. return parseInt(index) + 1
  165. }
  166. },
  167. {
  168. title: '图表',
  169. align: 'center',
  170. width: '15%',
  171. dataIndex: 'graphreportName',
  172. scopedSlots: { customRender: 'graphreportName' }
  173. },
  174. {
  175. title: '图表类型',
  176. align: 'center',
  177. width: '12%',
  178. dataIndex: 'graphreportType',
  179. scopedSlots: { customRender: 'graphreportType' }
  180. },
  181. {
  182. title: '分组编号',
  183. align: 'center',
  184. dataIndex: 'groupNum',
  185. width: '8%',
  186. scopedSlots: { customRender: 'groupNum' }
  187. },
  188. {
  189. title: '分组描述',
  190. align: 'center',
  191. dataIndex: 'groupTxt',
  192. width: '12%',
  193. scopedSlots: { customRender: 'groupTxt' }
  194. },
  195. {
  196. title: '分组展示风格',
  197. align: 'center',
  198. dataIndex: 'groupStyle',
  199. width: '15%',
  200. scopedSlots: { customRender: 'groupStyle' }
  201. },
  202. {
  203. title: '是否显示',
  204. align: 'center',
  205. dataIndex: 'isShow',
  206. width: '8%',
  207. scopedSlots: { customRender: 'isShow' }
  208. },
  209. {
  210. title: '组合栅格配置',
  211. align: 'center',
  212. dataIndex: 'templetGrid',
  213. width: '8%',
  214. scopedSlots: { customRender: 'templetGrid' }
  215. },
  216. {
  217. title: '分组栅格配置',
  218. align: 'center',
  219. dataIndex: 'groupGrid',
  220. width: '8%',
  221. scopedSlots: { customRender: 'groupGrid' }
  222. },
  223. {
  224. title: '排序',
  225. align: 'center',
  226. dataIndex: 'orderNum',
  227. width: '8%',
  228. scopedSlots: { customRender: 'orderNum' }
  229. }
  230. ],
  231. url: {
  232. list: '/online/cgform/head/list',
  233. edit: '/diagram/diagramCombination/edit',
  234. add: '/diagram/diagramCombination/add',
  235. graphreportList: '/diagram/diagramConfiguration/list'
  236. },
  237. scopedSlots: [
  238. { type: 'select', name: 'graphreportName' },
  239. { type: 'select', name: 'graphreportType' },
  240. { type: 'number', name: 'groupNum' },
  241. { type: 'text', name: 'groupTxt' },
  242. { type: 'select', name: 'groupStyle', dictCode: 'field_type' },
  243. { type: 'check', name: 'isShow' },
  244. { type: 'text', name: 'templetGrid' },
  245. { type: 'text', name: 'groupGrid' },
  246. { type: 'number', name: 'orderNum' }
  247. ],
  248. rules: {
  249. templetCode: [
  250. { required: true, message: '请输入组合报表编码', trigger: 'change' },
  251. { validator: (rule, value, callback) => validateDuplicateValue('cs_diagram_combination', 'templet_code', value, this.formData.id, callback) }
  252. ],
  253. templetName: [
  254. { required: true, message: '请输入组合报表名称', trigger: 'blur' }
  255. ],
  256. templetStyle: [
  257. { required: true, message: '请输入组合报表风格', trigger: 'change' }
  258. ]
  259. },
  260. formData: {
  261. 'createBy': '',
  262. 'createTime': '',
  263. 'id': '',
  264. 'templetCode': '',
  265. 'templetName': '',
  266. 'templetStyle': '',
  267. 'updateBy': '',
  268. 'updateTime': null,
  269. 'diagramCombinationDetails': [],
  270. 'diagramCombinationQueryConfigs': []
  271. },
  272. newFormData: {// 新增用数据
  273. 'createBy': '',
  274. 'createTime': '',
  275. 'id': '',
  276. 'templetCode': '',
  277. 'templetName': '',
  278. 'templetStyle': '',
  279. 'updateBy': '',
  280. 'updateTime': null,
  281. 'diagramCombinationDetails': []
  282. },
  283. newListFieldData: {
  284. 'createBy': '',
  285. 'createTime': '',
  286. 'graphreportCode': '',
  287. 'graphreportTempletId': '',
  288. 'graphreportType': '',
  289. 'groupNum': '',
  290. 'groupStyle': '',
  291. 'groupTxt': '',
  292. 'id': '',
  293. 'isShow': true,
  294. 'orderNum': '',
  295. 'updateBy': '',
  296. 'updateTime': '',
  297. 'templetGrid': '{"xl":12,"lg":12,"md":12,"sm":12}',
  298. 'groupGrid': '{"xl":12,"lg":12,"md":12,"sm":12}'
  299. },
  300. graphTypeDictOptions: CHART_LIST
  301. }
  302. },
  303. created() {
  304. getAction(this.url.graphreportList, {
  305. pageSize: 9999
  306. }).then((res) => {
  307. if (res.code === 200) {
  308. const that = this
  309. res.result.records.forEach(function(item, i) {
  310. that.graphreportNames.push({
  311. value: item.code,
  312. label: item.name
  313. })
  314. })
  315. } else {
  316. this.$message.error(res.message)
  317. }
  318. })
  319. },
  320. methods: {
  321. handleCancleDbSync() { // 关闭
  322. this.editModalVisible = false
  323. },
  324. edit(record) {
  325. var that = this
  326. const record_ = JSON.parse(JSON.stringify(record))
  327. Object.keys(that.formData).forEach(function(key) {
  328. that.formData[key] = record_[key]
  329. })
  330. this.editModalVisible = true
  331. },
  332. add() {
  333. var that = this
  334. const record_ = JSON.parse(JSON.stringify(that.newFormData))
  335. Object.keys(that.formData).forEach(function(key) {
  336. that.formData[key] = record_[key]
  337. })
  338. this.editModalVisible = true
  339. },
  340. async handleDbSync() { // 弹窗点击确定
  341. try {
  342. if (this.$refs.graphreportQueryConfig) {
  343. const { error, values } = await this.$refs.graphreportQueryConfig.getValuesSync()
  344. const valid = await this.$refs['ruleForm'].validate()
  345. if (!error && valid) {
  346. this.formData.diagramCombinationQueryConfigs = JSON.parse(JSON.stringify(values))
  347. this.updateData()
  348. }
  349. } else {
  350. const valid = await this.$refs['ruleForm'].validate()
  351. if (valid) {
  352. this.updateData()
  353. }
  354. }
  355. } catch (error) {
  356. console.log(error)
  357. }
  358. },
  359. updateData(params) { // 保存提交数据
  360. if (this.formData.id) {
  361. putAction(this.url.edit, this.formData).then((res) => {
  362. if (res.success) {
  363. this.$message.success(res.message)
  364. this.editModalVisible = false
  365. this.$emit('modalFormOk')
  366. } else {
  367. this.$message.warning(res.message)
  368. }
  369. }).finally(() => {
  370. // this.loading = false
  371. })
  372. } else {
  373. postAction(this.url.add, this.formData).then((res) => {
  374. if (res.success) {
  375. this.$message.success(res.message)
  376. this.editModalVisible = false
  377. this.$emit('modalFormOk')
  378. } else {
  379. this.$message.warning(res.message)
  380. }
  381. }).finally(() => {
  382. // this.loading = false
  383. })
  384. }
  385. },
  386. handleAddGraphRepoart() { // 新增
  387. const newData = JSON.parse(JSON.stringify(this.newListFieldData))
  388. newData.graphreportTempletId = this.formData.id
  389. const length_ = this.formData.diagramCombinationDetails.length
  390. if (length_ !== 0) {
  391. newData.orderNum = this.formData.diagramCombinationDetails[length_ - 1].orderNum + 1
  392. } else {
  393. newData.orderNum = 1
  394. }
  395. this.formData.diagramCombinationDetails.push(newData)
  396. },
  397. handleRemoveGraphRepoart() { // 删除
  398. var that = this
  399. this.selectedRowKeys.sort(function(a, b) { return b - a })
  400. this.selectedRowKeys.forEach(function(index) {
  401. that.formData.diagramCombinationDetails.splice(index, 1)
  402. })
  403. this.selectedRowKeys = []
  404. },
  405. onSelectChange(selectedRowKeys) {
  406. this.selectedRowKeys = selectedRowKeys
  407. },
  408. checkboxChange(data, name) {
  409. if (data[name]) {
  410. data[name] = 0
  411. } else {
  412. data[name] = 1
  413. }
  414. },
  415. combinationChange(key, val, groupNum) { // 值变化 相同图表编号随之改变
  416. this.formData.diagramCombinationDetails.forEach(element => {
  417. if (Number(element.groupNum) === Number(groupNum)) {
  418. element[key] = val
  419. }
  420. })
  421. },
  422. groupNumChange(record, index) {
  423. this.formData.diagramCombinationDetails.forEach(function(element, i) {
  424. if (i !== index && Number(element.groupNum) === Number(record.groupNum)) {
  425. record['groupStyle'] = element.groupStyle
  426. record['groupTxt'] = element.groupTxt
  427. }
  428. })
  429. },
  430. filterOption(input, option) {
  431. return (
  432. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  433. )
  434. }
  435. }
  436. }
  437. </script>
  438. <style>
  439. .warp .ant-select{
  440. width: 100%;
  441. }
  442. .warp .table-operator{
  443. margin-bottom: 10px;
  444. }
  445. .ant-card-body .warp {
  446. padding: 10px;
  447. }
  448. .warp .table-operator .ant-btn{
  449. margin: 0px 8px 0 0 !important;
  450. }
  451. .ant-card-body .warp .table-operator{
  452. margin-bottom:10px !important;
  453. }
  454. </style>