index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px">
  4. <el-form-item label="项目名称" prop="projectName">
  5. <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable style="width: 200px" @keyup.enter="handleQuery" />
  6. </el-form-item>
  7. <el-form-item label="填报月份" prop="month">
  8. <el-date-picker v-model="queryParams.month" type="month" value-format="YYYY-MM" placeholder="请选择月份" clearable style="width: 200px" />
  9. </el-form-item>
  10. <el-form-item label="审核状态" prop="reviewStatus">
  11. <el-select v-model="queryParams.reviewStatus" placeholder="审核状态" clearable style="width: 200px">
  12. <el-option label="待提交" value="DRAFT" />
  13. <el-option label="已提交待审核" value="SUBMITTED" />
  14. <el-option label="审核通过" value="APPROVED" />
  15. <el-option label="审核不通过" value="REJECTED" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  20. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <el-row :gutter="10" class="mb8">
  24. <el-col :span="1.5">
  25. <el-button type="primary" plain icon="Edit" @click="handleAdd" v-hasPermi="['performance:output:add']">填报产值</el-button>
  26. </el-col>
  27. <el-col :span="1.5">
  28. <el-button type="success" plain icon="Upload" :disabled="multiple" @click="handleBatchSubmit" v-hasPermi="['performance:output:submit']">批量提交</el-button>
  29. </el-col>
  30. <el-col :span="1.5">
  31. <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['performance:output:export']">导出</el-button>
  32. </el-col>
  33. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  34. </el-row>
  35. <el-table v-loading="loading" :data="outputList" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="50" align="center" />
  37. <el-table-column label="项目名称" align="center" prop="projectName" :show-overflow-tooltip="true" />
  38. <el-table-column label="填报月份" align="center" prop="month" />
  39. <el-table-column label="当月进度(%)" align="center" prop="currentProgress" />
  40. <el-table-column label="当月产值(万元)" align="center" prop="currentOutput" />
  41. <el-table-column label="协作产值(万元)" align="center" prop="coopOutput" />
  42. <el-table-column label="审核状态" align="center" prop="reviewStatus">
  43. <template #default="scope">
  44. <dict-tag :options="reviewStatusOptions" :value="scope.row.reviewStatus" />
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
  48. <template #default="scope">
  49. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-if="scope.row.reviewStatus === 'DRAFT'" v-hasPermi="['performance:output:edit']">修改</el-button>
  50. <el-button link type="primary" icon="Upload" @click="handleSubmit(scope.row)" v-if="scope.row.reviewStatus === 'DRAFT'" v-hasPermi="['performance:output:submit']">提交</el-button>
  51. <el-button link type="primary" icon="View" @click="handleDetail(scope.row)">详情</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
  56. <!-- 产值填报对话框 -->
  57. <el-dialog :title="title" v-model="open" width="650px" append-to-body>
  58. <el-form :model="form" :rules="rules" ref="outputRef" label-width="140px">
  59. <el-form-item label="项目" prop="projectId">
  60. <el-select v-model="form.projectId" placeholder="请选择项目" :disabled="form.outputId !== undefined" style="width: 100%">
  61. <el-option v-for="item in projectOptions" :key="item.projectId" :label="item.projectName" :value="item.projectId" />
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item label="填报月份" prop="month">
  65. <el-date-picker v-model="form.month" type="month" value-format="YYYY-MM" placeholder="请选择月份" :disabled="form.outputId !== undefined" style="width: 100%" />
  66. </el-form-item>
  67. <el-form-item label="当月实际进度(%)" prop="currentProgress">
  68. <el-input-number v-model="form.currentProgress" :precision="1" :min="0" :max="100" placeholder="请输入当月实际进度" style="width: 100%" />
  69. </el-form-item>
  70. <el-form-item label="当月实际产值(万元)" prop="currentOutput">
  71. <el-input-number v-model="form.currentOutput" :precision="4" :min="0" placeholder="请输入当月实际产值" style="width: 100%" />
  72. </el-form-item>
  73. <el-form-item label="进度说明" prop="description">
  74. <el-input v-model="form.description" type="textarea" placeholder="请输入进度说明" maxlength="500" />
  75. </el-form-item>
  76. </el-form>
  77. <template #footer>
  78. <div class="dialog-footer">
  79. <el-button type="primary" @click="submitForm">保 存</el-button>
  80. <el-button @click="cancel">取 消</el-button>
  81. </div>
  82. </template>
  83. </el-dialog>
  84. </div>
  85. </template>
  86. <script setup name="PerformanceOutput">
  87. import { listOutput, getOutput, addOutput, updateOutput, submitOutput } from '@/api/performance/output'
  88. const { proxy } = getCurrentInstance()
  89. const reviewStatusOptions = ref([
  90. { label: '待提交', value: 'DRAFT' },
  91. { label: '已提交待审核', value: 'SUBMITTED' },
  92. { label: '审核通过', value: 'APPROVED' },
  93. { label: '审核不通过', value: 'REJECTED' }
  94. ])
  95. const outputList = ref([])
  96. const open = ref(false)
  97. const loading = ref(true)
  98. const showSearch = ref(true)
  99. const ids = ref([])
  100. const single = ref(true)
  101. const multiple = ref(true)
  102. const total = ref(0)
  103. const title = ref('')
  104. const projectOptions = ref([])
  105. const data = reactive({
  106. form: {},
  107. queryParams: {
  108. pageNum: 1,
  109. pageSize: 10,
  110. projectName: undefined,
  111. month: undefined,
  112. reviewStatus: undefined
  113. },
  114. rules: {
  115. projectId: [{ required: true, message: '项目不能为空', trigger: 'change' }],
  116. month: [{ required: true, message: '填报月份不能为空', trigger: 'change' }],
  117. currentProgress: [{ required: true, message: '当月实际进度不能为空', trigger: 'blur' }],
  118. currentOutput: [{ required: true, message: '当月实际产值不能为空', trigger: 'blur' }]
  119. }
  120. })
  121. const { queryParams, form, rules } = toRefs(data)
  122. function getList() {
  123. loading.value = true
  124. listOutput(queryParams.value).then(res => {
  125. outputList.value = res.rows
  126. total.value = res.total
  127. loading.value = false
  128. })
  129. }
  130. function handleQuery() {
  131. queryParams.value.pageNum = 1
  132. getList()
  133. }
  134. function resetQuery() {
  135. proxy.resetForm('queryRef')
  136. handleQuery()
  137. }
  138. function handleSelectionChange(selection) {
  139. ids.value = selection.map(item => item.outputId)
  140. single.value = selection.length !== 1
  141. multiple.value = !selection.length
  142. }
  143. function reset() {
  144. form.value = {
  145. outputId: undefined,
  146. projectId: undefined,
  147. month: undefined,
  148. currentProgress: undefined,
  149. currentOutput: undefined,
  150. description: undefined
  151. }
  152. proxy.resetForm('outputRef')
  153. }
  154. function cancel() {
  155. open.value = false
  156. reset()
  157. }
  158. function handleAdd() {
  159. reset()
  160. open.value = true
  161. title.value = '产值填报'
  162. }
  163. function handleUpdate(row) {
  164. reset()
  165. getOutput(row.outputId).then(res => {
  166. form.value = res.data
  167. open.value = true
  168. title.value = '修改产值填报'
  169. })
  170. }
  171. function handleDetail(row) {
  172. // TODO: 查看填报详情
  173. }
  174. function handleSubmit(row) {
  175. proxy.$modal.confirm('确认提交该条产值填报?提交后将无法修改。').then(() => {
  176. return submitOutput(row.outputId)
  177. }).then(() => {
  178. proxy.$modal.msgSuccess('提交成功')
  179. getList()
  180. }).catch(() => {})
  181. }
  182. function handleBatchSubmit() {
  183. if (ids.value.length === 0) {
  184. proxy.$modal.msgWarning('请选择要提交的填报记录')
  185. return
  186. }
  187. proxy.$modal.confirm('确认批量提交选中的产值填报?').then(() => {
  188. const tasks = ids.value.map(id => submitOutput(id))
  189. return Promise.all(tasks)
  190. }).then(() => {
  191. proxy.$modal.msgSuccess('批量提交成功')
  192. getList()
  193. }).catch(() => {})
  194. }
  195. function handleExport() {
  196. proxy.download('/performance/output/export', { ...queryParams.value }, `output_${new Date().getTime()}.xlsx`)
  197. }
  198. function submitForm() {
  199. proxy.$refs.outputRef.validate(valid => {
  200. if (valid) {
  201. if (form.value.outputId) {
  202. updateOutput(form.value).then(() => {
  203. proxy.$modal.msgSuccess('修改成功')
  204. open.value = false
  205. getList()
  206. })
  207. } else {
  208. addOutput(form.value).then(() => {
  209. proxy.$modal.msgSuccess('填报成功')
  210. open.value = false
  211. getList()
  212. })
  213. }
  214. }
  215. })
  216. }
  217. onMounted(() => {
  218. getList()
  219. })
  220. </script>