index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. :page-size="defPageSize"
  7. ref="table"
  8. row-key="id"
  9. :columns="columns"
  10. :datasource="datasource"
  11. :default-expand-all="false"
  12. :need-page="false"
  13. @columns-change="handleColumnChange"
  14. :selection.sync="selection"
  15. :cache-key="cacheKeyUrl"
  16. >
  17. <!-- 表头工具栏 -->
  18. <template v-slot:toolbar>
  19. <el-button
  20. size="small"
  21. type="primary"
  22. icon="el-icon-plus"
  23. class="ele-btn-icon"
  24. @click="openEdit('add')"
  25. v-if="$hasPermission('main:basicarea:save') && !isModal"
  26. >
  27. 添加
  28. </el-button>
  29. <el-button class="ele-btn-icon" size="small" @click="expandAll">
  30. 展开全部
  31. </el-button>
  32. <el-button class="ele-btn-icon" size="small" @click="foldAll">
  33. 折叠全部
  34. </el-button>
  35. </template>
  36. <!-- 标题列 -->
  37. <template v-slot:areaImg="{ row }">
  38. <fileMain v-model="row.areaImg" type="view"></fileMain>
  39. </template>
  40. <!-- 操作列 -->
  41. <template v-slot:action="{ row }">
  42. <el-link
  43. type="primary"
  44. :underline="false"
  45. icon="el-icon-edit"
  46. @click="openEdit('update', row)"
  47. v-if="$hasPermission('main:basicarea:update')"
  48. >
  49. 修改
  50. </el-link>
  51. <el-popconfirm
  52. class="ele-action"
  53. title="确定要删除吗?"
  54. @confirm="remove(row)"
  55. v-if="row.id != 99999 && $hasPermission('main:basicarea:delete')"
  56. >
  57. <template v-slot:reference>
  58. <el-link type="danger" :underline="false" icon="el-icon-delete">
  59. 删除
  60. </el-link>
  61. </template>
  62. </el-popconfirm>
  63. <el-link
  64. type="primary"
  65. :underline="false"
  66. icon="el-icon-s-goods"
  67. @click="openPriceScheme(row)"
  68. >
  69. 用能价格方案
  70. </el-link>
  71. </template>
  72. </ele-pro-table>
  73. </el-card>
  74. <!-- 编辑弹窗 -->
  75. <area-edit
  76. v-if="showEdit"
  77. :visibleFlag.sync="showEdit"
  78. ref="areaEditRef"
  79. :data="editData"
  80. :parent-id="parentId"
  81. :organization-list="dataTree"
  82. @done="reload"
  83. />
  84. <!-- 用能价格方案弹窗 -->
  85. <energyPriceConfig
  86. v-if="showPriceScheme"
  87. ref="energyPriceConfigRef"
  88. @success="handlePriceSchemeSuccess"
  89. />
  90. </div>
  91. </template>
  92. <script>
  93. import tabMixins from '@/mixins/tableColumnsMixin';
  94. import areaEdit from './components/area-edit.vue';
  95. import energyPriceConfig from './components/energyPriceConfig.vue';
  96. import {
  97. basicAreaDeleteAPI,
  98. basicAreaPageAPI,
  99. energyPricingConfiguration
  100. } from '@/api/regionalManage';
  101. import dictMixins from '@/mixins/dictMixins';
  102. export default {
  103. props: {
  104. isModal: {
  105. type: Boolean,
  106. default: false
  107. }
  108. },
  109. mixins: [tabMixins, dictMixins],
  110. name: 'SystemOrganization',
  111. components: { areaEdit, energyPriceConfig },
  112. data() {
  113. return {
  114. // 加载状态
  115. loading: false,
  116. // 列表数据
  117. data: [],
  118. dataTree: [],
  119. // 选中数据
  120. current: null,
  121. // 是否显示表单弹窗
  122. showEdit: false,
  123. // 编辑回显数据
  124. editData: null,
  125. // 上级id
  126. selection: [],
  127. parentId: null,
  128. dictList: {},
  129. cacheKeyUrl: 'fb2f4315-enterpriseModel-organization',
  130. columnsVersion: 1,
  131. // 价格方案弹窗
  132. showPriceScheme: false,
  133. priceSchemeRow: null,
  134. disabledList: []
  135. };
  136. },
  137. computed: {
  138. // 表格列配置
  139. columns() {
  140. const version = this.columnsVersion;
  141. return [
  142. {
  143. columnKey: 'index',
  144. type: 'index',
  145. width: 45,
  146. align: 'center',
  147. showOverflowTooltip: true,
  148. fixed: 'left'
  149. },
  150. {
  151. columnKey: 'selection',
  152. type: 'selection',
  153. align: 'center',
  154. isNone: !this.isModal,
  155. // selectable: (row, index) => {
  156. // return !this.disabledList.includes(row.id);
  157. // },
  158. width: 55
  159. },
  160. {
  161. prop: 'name',
  162. label: '区域名称',
  163. showOverflowTooltip: true,
  164. align: 'center',
  165. minWidth: 110,
  166. slot: 'name'
  167. },
  168. {
  169. prop: 'areaCode',
  170. label: '区域编码',
  171. showOverflowTooltip: true,
  172. align: 'center',
  173. minWidth: 110
  174. },
  175. {
  176. prop: 'areaImg',
  177. label: '地图/示意图',
  178. showOverflowTooltip: true,
  179. align: 'center',
  180. minWidth: 110,
  181. slot: 'areaImg'
  182. },
  183. {
  184. prop: 'areaLevel',
  185. label: '区域等级',
  186. showOverflowTooltip: true,
  187. align: 'center',
  188. formatter: (row, column) => {
  189. return this.getDictValue('区域等级', row.areaLevel);
  190. },
  191. minWidth: 110
  192. },
  193. {
  194. prop: 'areaType',
  195. label: '区域类型',
  196. showOverflowTooltip: true,
  197. align: 'center',
  198. formatter: (row, column) => {
  199. return this.getDictValue('区域类型', row.areaType);
  200. },
  201. minWidth: 110
  202. },
  203. {
  204. prop: 'areaSort',
  205. label: '排序',
  206. showOverflowTooltip: true,
  207. align: 'center',
  208. width: 60
  209. },
  210. {
  211. columnKey: 'action',
  212. label: '操作',
  213. width: 250,
  214. align: 'center',
  215. resizable: false,
  216. isNone: this.isModal,
  217. slot: 'action',
  218. showOverflowTooltip: true
  219. }
  220. ].filter((item) => !item.isNone);
  221. }
  222. },
  223. created() {
  224. this.requestDict('区域类型');
  225. this.requestDict('区域等级');
  226. },
  227. methods: {
  228. /* 查询 */
  229. async datasource() {
  230. const data = await basicAreaPageAPI({
  231. pageNum: 1,
  232. size: 9999
  233. });
  234. this.data = this.$util.toTreeData({
  235. data: data,
  236. idField: 'id',
  237. parentIdField: 'parentId'
  238. });
  239. this.dataTree = [
  240. {
  241. name: '顶级区域',
  242. id: '0',
  243. children: this.data
  244. }
  245. ];
  246. return this.data;
  247. },
  248. /* 刷新表格 */
  249. reload(where) {
  250. this.$refs.table.reload();
  251. },
  252. /* 展开全部 */
  253. expandAll() {
  254. this.$refs.table.toggleRowExpansionAll(true);
  255. },
  256. /* 折叠全部 */
  257. foldAll() {
  258. this.$refs.table.toggleRowExpansionAll(false);
  259. },
  260. /* 显示编辑 */
  261. openEdit(type, row) {
  262. this.showEdit = true;
  263. this.$nextTick(() => {
  264. this.$refs.areaEditRef.init(type, row);
  265. });
  266. },
  267. getTabelValue() {
  268. return this.selection;
  269. },
  270. setValue(value = []) {
  271. this.selection = [];
  272. this.$refs.table.clearSelection()
  273. // this.disabledList = value;
  274. },
  275. /* 删除 */
  276. remove(row) {
  277. this.$confirm('确定要删除选中的区域吗?', '提示', {
  278. type: 'warning'
  279. })
  280. .then(() => {
  281. const loading = this.$loading({ lock: true });
  282. basicAreaDeleteAPI([row.id])
  283. .then((msg) => {
  284. loading.close();
  285. this.$message.success(msg);
  286. this.reload();
  287. })
  288. .catch((e) => {
  289. loading.close();
  290. // this.$message.error(e.message);
  291. });
  292. })
  293. .catch(() => {});
  294. },
  295. /* 打开用能价格方案 */
  296. openPriceScheme(row) {
  297. this.priceSchemeRow = row;
  298. this.showPriceScheme = true;
  299. this.$nextTick(() => {
  300. this.$refs.energyPriceConfigRef.open(row);
  301. });
  302. },
  303. /* 价格方案配置成功 */
  304. handlePriceSchemeSuccess(data) {
  305. energyPricingConfiguration(data).then((res) => {
  306. this.$message.success('配置成功');
  307. this.reload();
  308. });
  309. }
  310. }
  311. };
  312. </script>
  313. <style lang="scss" scoped>
  314. .sys-organization-list {
  315. height: calc(100vh - 264px);
  316. box-sizing: border-box;
  317. border-width: 1px;
  318. border-style: solid;
  319. overflow: auto;
  320. }
  321. .sys-organization-list :deep(.el-tree-node__content) {
  322. height: 30px;
  323. & > .el-tree-node__expand-icon {
  324. margin-left: 10px;
  325. }
  326. }
  327. </style>