index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <el-row class="el-row-container" v-loading="loading">
  3. <el-col
  4. :span="24"
  5. style="padding: 16px; height: 100%"
  6. >
  7. <el-card style="height: 100%; overflow-y: auto">
  8. <el-col :span="24" class="elrow-main__col-top">
  9. <div style="display: flex;">
  10. <select-tree
  11. :placeholder="'年份'"
  12. style="width: 250px"
  13. :treeData="treeData"
  14. @handlerClick="handlerClick"
  15. :checkVal="cusareaName"
  16. ></select-tree>
  17. <el-input
  18. style="width: 250px;margin: 0 16px;"
  19. placeholder="请输入关键字"
  20. v-model="subsidypolicyTitle"
  21. />
  22. <el-button
  23. type="primary"
  24. size="small"
  25. @click="handleSearch"
  26. >查询</el-button
  27. >
  28. </div>
  29. <div class="top-left">
  30. <el-button
  31. type="primary"
  32. size="small"
  33. @click="addAssociation"
  34. >发布新政策
  35. </el-button
  36. ></div>
  37. </el-col>
  38. <el-col :span="24" class="elrow-main__col-bottom">
  39. <b-table
  40. ref="tableRef"
  41. :args="{ 'highlight-current-row': true }"
  42. :data="loadData"
  43. :columns="columns"
  44. isShowIndex
  45. >
  46. <template #styleImg="scope">
  47. <el-image
  48. :src="dialogImageUrl + scope.row.previews || ''"
  49. :preview-src-list="[dialogImageUrl + scope.row.previews || '']"
  50. slot="error"
  51. class="image-slot"
  52. style="width: 100px; height: 50px"
  53. >
  54. <div slot="error" class="image-slot"></div>
  55. </el-image>
  56. </template>
  57. <template #operate="scope">
  58. <el-link
  59. size="small"
  60. :underline="false"
  61. type="primary"
  62. style="margin-right: 10px"
  63. @click="editHandler(scope.row)"
  64. >修改</el-link
  65. >
  66. <el-link
  67. size="small"
  68. :underline="false"
  69. type="danger"
  70. style="margin-right: 10px"
  71. @click="deleteHandler(scope.row)"
  72. >删除</el-link
  73. >
  74. </template>
  75. </b-table>
  76. </el-col>
  77. </el-card>
  78. </el-col>
  79. <new-policy
  80. :visible.sync="showPolicy"
  81. :policyType="policyType"
  82. :areaId="areaId"
  83. :editRow="editRow"
  84. @addSuccess="addSuccessHandler"
  85. />
  86. </el-row>
  87. </template>
  88. <script>
  89. import { getSubsidyPolicy, deleteSubsidyPolicy } from '@/api/subsidypolicy/index.js'
  90. import SelectTree from '@/components/SelectTree';
  91. import BTable from '@/components/Table/index.vue';
  92. import { getTree } from '@/api/tree.js'
  93. import newPolicy from './components/newPolicy.vue'
  94. import { Message } from 'element-ui'
  95. export default {
  96. name:'waterSubsidy',
  97. components: { BTable,newPolicy, SelectTree },
  98. data() {
  99. return {
  100. form: {
  101. productName: ''
  102. },
  103. policyType: 'add',
  104. subsidypolicyTitle:'',
  105. loading: false,
  106. showPolicy: false,
  107. treeData: [],
  108. areaId: '',
  109. cusareaName: '',
  110. editRow: {},
  111. dialogImageUrl: '',
  112. columns: [
  113. {
  114. label: '图片',
  115. prop: 'previews',
  116. customRender: 'styleImg',
  117. align: 'center'
  118. },
  119. {
  120. label: '标题',
  121. prop: 'subsidypolicyTitle',
  122. customRender: '',
  123. align: 'center'
  124. },
  125. {
  126. label: '浏览量',
  127. prop: 'subsidypolicyReadnum',
  128. customRender: '',
  129. align: 'center'
  130. },
  131. {
  132. label: '发布人',
  133. prop: 'subsidypolicyCreatorName',
  134. customRender: '',
  135. align: 'center'
  136. },{
  137. label: '发布时间',
  138. prop: 'subsidypolicyCreateddate',
  139. customRender: '',
  140. align: 'center'
  141. },
  142. {
  143. label: '操作',
  144. customRender: 'operate',
  145. align: 'center'
  146. }
  147. ]
  148. };
  149. },
  150. mounted() {
  151. this.dialogImageUrl = process.env.VUE_APP_BASE_API
  152. },
  153. methods: {
  154. addSuccessHandler() {
  155. this.handleSearch()
  156. },
  157. addAssociation() {
  158. this.policyType = 'add'
  159. this.showPolicy = true
  160. },
  161. async loadData() {
  162. if (!this.areaId) {
  163. const treeList = this.$store.state.tree.treeList
  164. let res = []
  165. if (treeList.code === '000000') {
  166. res = treeList
  167. } else {
  168. res = await getTree()
  169. this.$store.dispatch('tree/setTree', res)
  170. }
  171. this.treeData = res?.data
  172. this.cusareaName ||= this.treeData[0].cusareaName
  173. this.areaId = this.treeData[0].cusareaId
  174. }
  175. return this.getWaterrightListHandler()
  176. },
  177. getWaterrightListHandler() {
  178. return getSubsidyPolicy({
  179. areaIds: this.areaId,
  180. subsidypolicyTitle: this.subsidypolicyTitle
  181. })
  182. },
  183. handlerClick(value) {
  184. this.areaId = value?.cusareaId
  185. },
  186. handleSearch() {
  187. this.$refs.tableRef.refresh(true);
  188. },
  189. goDetail(row) {
  190. this.$refs.sourceCodeDetail.open(row.tarcecodeapplyBatchno)
  191. },
  192. editHandler(row) {
  193. this.policyType = 'edit'
  194. const params = {
  195. subsidypolicyTitle: row?.subsidypolicyTitle,
  196. src: this.dialogImageUrl + row?.previews,
  197. subsidypolicyContent: row?.subsidypolicyContent,
  198. subsidypolicyId: row?.subsidypolicyId
  199. }
  200. this.editRow = params
  201. this.showPolicy = true
  202. },
  203. deleteHandler(row) {
  204. const { subsidypolicyId } = row
  205. this.$modal
  206. .confirm(`是否确认删除`)
  207. .then(() => {
  208. deleteSubsidyPolicy({
  209. subsidypolicyIds: subsidypolicyId
  210. }).then(() => {
  211. Message({ message: "删除成功", type: 'success' });
  212. this.handleSearch()
  213. })
  214. })
  215. }
  216. }
  217. };
  218. </script>
  219. <style lang="scss" scoped>
  220. .el-row-container{
  221. height: 100%;
  222. }
  223. .elrow-main__col-top {
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. margin-bottom: 15px;
  228. .top-left {
  229. height: 100%;
  230. display: flex;
  231. align-items: center;
  232. i {
  233. background-color: #40d5ec;
  234. height: 45%;
  235. width: 5px;
  236. margin-right: 5px;
  237. }
  238. }
  239. }
  240. </style>