index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36">
  5. <el-select v-model="searchForm.department" block clearable placeholder="选择部门" size="large">
  6. <el-option v-for="item in department" :label="item.name" :value="item.key"/>
  7. </el-select>
  8. </div>
  9. <div class="w-36 ml-4">
  10. <el-date-picker class="block" v-model="searchForm.planStartDate" type="month" value-format="YYYY-MM" placeholder="开始日期" clearable size="large"/>
  11. </div>
  12. <div class="mx-2">~</div>
  13. <div class="w-36">
  14. <el-date-picker class="block" v-model="searchForm.planEndDate" type="month" value-format="YYYY-MM" placeholder="结束日期" clearable size="large"/>
  15. </div>
  16. <div class="ml-4">
  17. <el-button size="large" type="primary" @click="searchClick">
  18. <HcIcon name="search-2"/>
  19. <span>搜索</span>
  20. </el-button>
  21. </div>
  22. <div class="ml-2">
  23. <el-button size="large" @click="resetClick">
  24. <HcIcon name="close-circle"/>
  25. <span>重置</span>
  26. </el-button>
  27. </div>
  28. </template>
  29. <template #extra>
  30. <el-button size="large" type="primary" hc-btn @click="addRowClick">
  31. <HcIcon name="add"/>
  32. <span>新增预算计划</span>
  33. </el-button>
  34. </template>
  35. <HcTable :column="tableColumn" :datas="tableData" :loading="tableLoading">
  36. <template #planName="{row}">
  37. <span class="text-blue" @click="rowNameClick(row)">{{row.planName}}</span>
  38. </template>
  39. <template #key2="{row}">
  40. <span >{{row.planStartDate?row.planStartDate:''}}</span>
  41. <span v-if="row.planStartDate">~</span>
  42. <span >{{row.planStartDate?row.planStartDate:''}}</span>
  43. </template>
  44. <template #planTotal="{row}">
  45. <span>{{row.planTotal}}条</span>
  46. </template>
  47. <template #finishPlanTotal="{row}">
  48. <span>{{row.finishPlanTotal}}条</span>
  49. </template>
  50. <template #beginPlanTotal="{row}">
  51. <span>{{row.beginPlanTotal}}条</span>
  52. </template>
  53. <template #action="{row,index}">
  54. <el-button size="small" type="primary" @click="editRowClick(row)">编辑</el-button>
  55. <el-button size="small" type="danger">删除</el-button>
  56. </template>
  57. </HcTable>
  58. <template #action>
  59. <HcPages :pages="searchForm" @change="pageChange"/>
  60. </template>
  61. <!--选择计划所属月份-->
  62. <HcDialog bgColor="#ffffff" isToBody title="选择计划所属月份" widths="26rem" saveText="确认"
  63. :show="monthModal" @close="monthCloseClick" @save="monthSaveClick"
  64. >
  65. <el-form ref="formMonthRef" label-position="top" size="large" :model="formMonthModel" :rules="formMonthRules">
  66. <el-form-item label="选择部门" prop="section">
  67. <el-select v-model="formMonthModel.section" block placeholder="选择部门">
  68. <el-option v-for="item in department" :label="item.name" :value="item.key"/>
  69. </el-select>
  70. </el-form-item>
  71. <el-form-item label="选择月份" prop="month">
  72. <el-date-picker type="month" class="block" v-model="formMonthModel.month" format="YYYY-MM" value-format="YYYY-MM"/>
  73. </el-form-item>
  74. </el-form>
  75. </HcDialog>
  76. </HcCard>
  77. </template>
  78. <script setup>
  79. import {ref,onMounted,onActivated} from "vue";
  80. import {useRouter} from 'vue-router'
  81. import {getArrValue} from "js-fast-way"
  82. import sectionApi from '~api/program/section.js';
  83. const router = useRouter()
  84. onActivated(()=>{
  85. getTableData()
  86. })
  87. //选择部门
  88. const department = ref([
  89. {name: '研发部门', key: '1'},
  90. {name: '业务部门', key: '2'},
  91. {name: '人事部门', key: '3'},
  92. ])
  93. //搜索表单
  94. const searchForm = ref({
  95. planType: null, startTime: null, endTime: null, department: null, queryValue: '',
  96. current: 1, size: 20, total: 0
  97. })
  98. //搜索
  99. const searchClick = () => {
  100. searchForm.value.current = 1;
  101. getTableData()
  102. }
  103. //重置搜索表单
  104. const resetClick = () => {
  105. searchForm.value = {current: 1, size: 20, total: 0}
  106. }
  107. //分页被点击
  108. const pageChange = ({current, size}) => {
  109. searchForm.value.current = current
  110. searchForm.value.size = size
  111. getTableData()
  112. }
  113. //获取数据
  114. const tableLoading = ref(false)
  115. const tableColumn = [
  116. {key: 'planName', name: '计划名称'},
  117. {key: 'key2', name: '计划起止日期', width: '220', align: 'center'},
  118. {key: 'planTotal', name: '计划数量', width: '120', align: 'center'},
  119. {key: 'finishPlanTotal', name: '已完成计划', width: '120', align: 'center'},
  120. {key: 'beginPlanTotal', name: '未完成计划', width: '120', align: 'center'},
  121. {key: 'planDesigner', name: '计划制定人', width: '120', align: 'center'},
  122. {key: 'action', name: '操作', width: '160', align: 'center'},
  123. ]
  124. const tableData = ref([
  125. {id: 1, key1: '2023年5月度计划', key2: '2022-07-01~2027-04-12', key3: '36', key4: '30', key5: '6', key6: '张三'},
  126. {id: 2, key1: '2023年5月度计划', key2: '2022-07-01~2027-04-12', key3: '36', key4: '30', key5: '6', key6: '张三'},
  127. {id: 3, key1: '2023年5月度计划', key2: '2022-07-01~2027-04-12', key3: '36', key4: '30', key5: '6', key6: '张三'},
  128. ])
  129. const getTableData = async() => {
  130. tableLoading.value = true
  131. const {error, code, data} = await sectionApi.getPage(searchForm.value)
  132. tableLoading.value = false
  133. if (!error && code === 200) {
  134. tableData.value = getArrValue(data)
  135. searchForm.value.total = data['total'] || 0
  136. } else {
  137. tableData.value = []
  138. searchForm.value.total = 0
  139. }
  140. }
  141. //表格名称被点击
  142. const rowNameClick = (row) => {
  143. }
  144. //新增计划
  145. const addRowClick = () => {
  146. monthModal.value = true
  147. }
  148. //获取所属部门列表
  149. const getDepartmentDict=()=>{
  150. }
  151. //选择月份
  152. const monthModal = ref(false)
  153. //选择月份的表单数据
  154. const formMonthRef = ref(null)
  155. const formMonthModel = ref({
  156. section: '', month: null
  157. })
  158. const formMonthRules = {
  159. section: [{required: true, message: '请选择部门', trigger: 'blur'}],
  160. month: [{required: true, message: '请选择月份', trigger: 'blur'}],
  161. }
  162. const monthCloseClick = () => {
  163. monthModal.value = false
  164. }
  165. //确认下一步
  166. const monthSaveClick = () => {
  167. monthModal.value = false
  168. router.push({
  169. name: 'program-section-form',
  170. query: formMonthModel.value
  171. })
  172. }
  173. //编辑预算
  174. const editRowClick = (row) => {
  175. router.push({
  176. name: 'program-index-info',
  177. query: {
  178. id: row.id
  179. }
  180. })
  181. }
  182. </script>