land.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <HcPageLayout>
  3. <template #left>
  4. <div class="hc-layout-tree-box">
  5. <el-scrollbar>
  6. <HcTreeData @nodeTap="treeNodeTap" />
  7. </el-scrollbar>
  8. </div>
  9. </template>
  10. <HcCard>
  11. <template #header>
  12. <div class="w-52">
  13. <el-input v-model="searchForm.name" clearable placeholder="请输入名称进行查询" size="large" />
  14. </div>
  15. <div class="ml-4">
  16. <el-button type="primary" size="large" @click="searchClick">
  17. <HcIcon name="search-2" />
  18. <span>搜索</span>
  19. </el-button>
  20. </div>
  21. </template>
  22. <template #extra>
  23. <el-button size="large" type="primary" hc-btn @click="addRowClick">
  24. <HcIcon name="add" />
  25. <span>新增</span>
  26. </el-button>
  27. <el-button size="large" type="warning" hc-btn>
  28. <HcIcon name="add" />
  29. <span>打印</span>
  30. </el-button>
  31. <el-button size="large" type="danger" hc-btn>
  32. <HcIcon name="delete-bin" />
  33. <span>删除</span>
  34. </el-button>
  35. </template>
  36. <HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading" is-check @selection-change="tableSelectionChange">
  37. <template #action="{ row, index }">
  38. <el-button size="small" type="primary" @click="editRowClick(row)">
  39. 修改
  40. </el-button>
  41. <el-button size="small" type="warning" @click="viewPdf(row)">
  42. 查看
  43. </el-button>
  44. <el-button size="small" type="danger" @click="delAgree(row)">
  45. 删除
  46. </el-button>
  47. </template>
  48. </HcTable>
  49. <template #action>
  50. <HcPages :pages="searchForm" @change="pageChange" />
  51. </template>
  52. </HcCard>
  53. </HcPageLayout>
  54. </template>
  55. <script setup>
  56. import { ref } from 'vue'
  57. import { useRouter } from 'vue-router'
  58. import landApi from '~api/agree/land.js'
  59. import { useAppStore } from '~src/store'
  60. import { getArrValue } from 'js-fast-way'
  61. import { delMessageV2 } from '~com/message/index.js'
  62. const useAppState = useAppStore()
  63. const projectId = ref(useAppState.getProjectId)
  64. const router = useRouter()
  65. const areaId = ref('')
  66. //树节点被点击
  67. const treeNodeTap = ({ node, data }) => {
  68. areaId.value = data.id
  69. searchForm.value.areaId = data.id
  70. getTableData()
  71. }
  72. //搜索表单
  73. const searchForm = ref({
  74. projectType: null, name: null, startTime: null, endTime: null,
  75. current: 1, size: 20, total: 0,
  76. })
  77. //搜索
  78. const searchClick = () => {
  79. searchForm.value.current = 1
  80. getTableData()
  81. }
  82. //分页被点击
  83. const pageChange = ({ current, size }) => {
  84. searchForm.value.current = current
  85. searchForm.value.size = size
  86. getTableData()
  87. }
  88. //获取数据
  89. const tableLoading = ref(false)
  90. const tableColumn = [
  91. { key: 'number', name: '协议编号' },
  92. { key: 'name', name: '协议书名称' },
  93. { key: 'landMoney', name: '地类补偿金额' },
  94. { key: 'cropsMoney', name: '青苗及附着物补偿金额' },
  95. { key: 'allMoney', name: '补偿总金额' },
  96. { key: 'action', name: '操作', width: '190', align: 'center' },
  97. ]
  98. const tableData = ref([
  99. ])
  100. const getTableData = async () => {
  101. tableLoading.value = true
  102. const { error, code, data } = await landApi.getPage({
  103. ...searchForm.value,
  104. projectId: projectId.value,
  105. type:1,
  106. })
  107. tableLoading.value = false
  108. if (!error && code === 200) {
  109. tableData.value = getArrValue(data['records'])
  110. searchForm.value.total = data['total'] || 0
  111. } else {
  112. tableData.value = []
  113. searchForm.value.total = 0
  114. }
  115. }
  116. //多选事件
  117. const tableSelectionChange = (rows) => {
  118. console.log(rows)
  119. }
  120. //新增
  121. const addRowClick = () => {
  122. router.push({
  123. name: 'lar-agree-land-form',
  124. query:{
  125. type:1,
  126. areaId:areaId.value,
  127. },
  128. })
  129. }
  130. //编辑
  131. const editRowClick = (row) => {
  132. router.push({
  133. name: 'lar-agree-land-form',
  134. query:{
  135. type:2,
  136. id:row.id,
  137. areaId:areaId.value,
  138. },
  139. })
  140. }
  141. //查看pdf
  142. const viewPdf = ({ mergePdfUrl }) => {
  143. if (mergePdfUrl) {
  144. window.open(mergePdfUrl, '_blank')
  145. } else {
  146. window.$message.error('暂无文件')
  147. }
  148. }
  149. const delAgree = (row)=>{
  150. delMessageV2(async (action, instance, done) => {
  151. if (action === 'confirm') {
  152. instance.confirmButtonLoading = true
  153. const { error, code, msg } = await landApi.remove({
  154. ids: row?.id,
  155. })
  156. if (!error && code === 200) {
  157. window?.$message?.success('删除成功')
  158. getTableData()
  159. } else {
  160. window?.$message?.warning(msg)
  161. }
  162. instance.confirmButtonLoading = false
  163. done()
  164. } else {
  165. done()
  166. }
  167. })
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .hc-layout-tree-box {
  172. position: relative;
  173. height: 100%;
  174. padding: 18px;
  175. }
  176. </style>