Newer
Older
Nanping_sponge_GCYPG / src / views / preassess / runoffCoefficient / index.vue
@liyingjing liyingjing on 25 Oct 2023 6 KB 工程预评估
  1. <template>
  2. <div class="runoffCoefficient">
  3. <div class="top">
  4. <el-form ref="ruleForm" inline :model="form">
  5. <el-form-item label="使用状态:" prop="status">
  6. <el-select v-model="form.status" placeholder="使用状态">
  7. <el-option label="全部" value="" />
  8. <el-option label="启用" value="1" />
  9. <el-option label="停用" value="0" />
  10. </el-select>
  11. </el-form-item>
  12. <el-form-item label="时间:" prop="time">
  13. <el-date-picker
  14. v-model="form.time"
  15. type="daterange"
  16. range-separator="~"
  17. start-placeholder="开始时间"
  18. end-placeholder="结束时间"
  19. format="YYYY-MM-DD"
  20. value-format="YYYY-MM-DD"
  21. />
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" icon="Search" @click="search">
  25. 查询</el-button>
  26. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-row class="mb8">
  30. <el-button type="primary" plain icon="Plus" @click="openDialog({}, 'add')">新增</el-button>
  31. </el-row>
  32. </div>
  33. <el-table :data="tableData" v-loading="loading" stripe :max-height="600">
  34. <el-table-column type="index" width="55" label="序号" align="center" />
  35. <el-table-column label="记录名称" prop="configName" show-overflow-tooltip width="200">
  36. <template #default="{ row }">
  37. <span style="color: #409eef">{{ row.configName }}</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="启用时间" align="center" prop="startDatetime" show-overflow-tooltip />
  41. <el-table-column label="停用时间" align="center" prop="endDatetime" show-overflow-tooltip />
  42. <el-table-column label="修改人" align="center" prop="updateNickName" show-overflow-tooltip />
  43. <el-table-column label="修改日期" align="center" prop="updateTime" show-overflow-tooltip />
  44. <el-table-column label="使用状态" align="center" prop="status" show-overflow-tooltip>
  45. <template #default="{ row }">
  46. <el-tag :type="statusMap.get(row.status).type" v-if="row.status">{{ statusMap.get(row.status).text }}</el-tag>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="操作" align="center" show-overflow-tooltip width="254">
  50. <template #default="{ row }">
  51. <el-button type="primary" link @click="copy(row)">复制</el-button>
  52. <el-button type="primary" link @click="enable(row)" :disabled="row.status === '1'">启用</el-button>
  53. <el-button type="primary" link @click="openDialog(row, 'view')">查看</el-button>
  54. <el-button type="primary" link @click="openDialog(row, 'edit')">修改</el-button>
  55. <el-button type="danger" link @click="del(row)">删除</el-button>
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
  60. <el-dialog
  61. v-model="visible"
  62. :title="`${opts.text}建议径流系数`"
  63. :close-on-click-modal="false"
  64. width="70%"
  65. :before-close="close"
  66. class="dialog"
  67. >
  68. <tableDalgo v-if="visible" ref="tableDalgoRef" :id="row.id || ''" :opts="opts.type" @close="close"></tableDalgo>
  69. </el-dialog>
  70. </div>
  71. </template>
  72.  
  73. <script setup>
  74. import tableDalgo from './tableDalgo.vue'
  75. import {
  76. getUnderlyingSurfaceRunoffConfigPage,
  77. underlyingSurfaceRunoffConfigDel,
  78. underlyingSurfaceRunoffConfigCopy,
  79. underlyingSurfaceRunoffConfigEnable
  80. } from '@/api/preassess/runoffCoefficient.js'
  81. import { reactive, ref, onMounted, computed } from 'vue'
  82. import { optTextMap, statusMap } from '@/utils/map'
  83. import { usePagination } from '@/hooks'
  84. const { proxy } = getCurrentInstance();
  85. const form = reactive({
  86. status: '',
  87. time: []
  88. })
  89. const params = computed(() => {
  90. const args = JSON.parse(JSON.stringify(form))
  91. const { time } = args
  92. delete args.time
  93. return {
  94. ...args,
  95. updateTimeStart: time[0] || '',
  96. updateTimeEnd: time[1] || ''
  97. }
  98. })
  99. const {
  100. pageNum,
  101. pageSize,
  102. tableData,
  103. total,
  104. loading,
  105. getTableList
  106. } = usePagination(getUnderlyingSurfaceRunoffConfigPage, params)
  107. const visible = ref(false)
  108. const row = ref({})
  109. const opts = reactive({
  110. type: '',
  111. text: ''
  112. })
  113.  
  114. const search = () => {
  115. pageNum.value = 1
  116. getTableList()
  117. }
  118.  
  119. const resetQuery = () => {
  120. proxy.$refs.ruleForm.resetFields()
  121. getTableList()
  122. }
  123.  
  124. const openDialog = (data, type) => {
  125. visible.value = true
  126. opts.type = type
  127. opts.text = optTextMap.get(type)
  128. row.value = data
  129. }
  130.  
  131. const close = (type) => {
  132. visible.value = false
  133. opts.type = ''
  134. opts.text = ''
  135. row.value = {}
  136. if(type === 'add') search()
  137. if(type && ['add', 'edit'].includes(type)) proxy.$modal.msgSuccess('操作成功!')
  138. }
  139.  
  140. const del = (row) => {
  141. proxy.$modal
  142. .confirm("是否确认删除?")
  143. .then(async () => {
  144. const res = await underlyingSurfaceRunoffConfigDel(row.id)
  145. if(res?.code !== 200) return
  146. proxy.$modal.msgSuccess('操作成功!')
  147. getTableList()
  148. })
  149. .catch(() => {});
  150. }
  151.  
  152. const copy = (row) => {
  153. proxy.$modal
  154. .confirm("是否确认复制?")
  155. .then(async () => {
  156. const res = await underlyingSurfaceRunoffConfigCopy({ id: row.id })
  157. if(res?.code !== 200) return
  158. proxy.$modal.msgSuccess('操作成功!')
  159. getTableList()
  160. })
  161. .catch(() => {});
  162. }
  163.  
  164. const enable = (row) => {
  165. proxy.$modal
  166. .confirm("是否确认启用?")
  167. .then(async () => {
  168. const res = await underlyingSurfaceRunoffConfigEnable(row.id)
  169. if(res?.code !== 200) return
  170. proxy.$modal.msgSuccess('操作成功!')
  171. getTableList()
  172. })
  173. .catch(() => {});
  174. }
  175.  
  176. onMounted(() => {
  177. getTableList()
  178. })
  179. </script>
  180.  
  181. <style lang="scss" scoped>
  182. .runoffCoefficient {
  183. padding: 20px;
  184. height: 90vh;
  185. overflow-y: hidden;
  186. .top {
  187. margin-bottom: 15px;
  188. }
  189. }
  190.  
  191. ::v-deep(.dialog) {
  192. .el-dialog__body {
  193. padding-bottom: 20px !important;
  194. }
  195. .el-dialog__footer {
  196. padding-top: 0 !important;
  197. }
  198. .innerDialog {
  199. .el-dialog__body {
  200. padding-bottom: 0 !important;
  201. }
  202. }
  203. }
  204. </style>