index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36">
  5. <el-select v-model="searchForm.planType" block clearable placeholder="计划类型" size="large">
  6. <el-option v-for="item in planType" :label="item.name" :value="item.key"/>
  7. </el-select>
  8. </div>
  9. <div class="w-36 ml-2">
  10. <el-select v-model="searchForm.department" block clearable placeholder="选择部门" size="large">
  11. <el-option v-for="item in department" :label="item.name" :value="item.key"/>
  12. </el-select>
  13. </div>
  14. <div class="w-36 ml-4">
  15. <el-date-picker class="block" v-model="searchForm.startTime" type="month" value-format="YYYY-MM" placeholder="开始日期" clearable size="large"/>
  16. </div>
  17. <div class="mx-2">~</div>
  18. <div class="w-36">
  19. <el-date-picker class="block" v-model="searchForm.endTime" type="month" value-format="YYYY-MM" placeholder="结束日期" clearable size="large"/>
  20. </div>
  21. <div class="w-40 ml-2">
  22. <el-input v-model="searchForm.queryValue" clearable placeholder="请输入计划名称" @keyup="keyUpEvent" size="large"/>
  23. </div>
  24. <div class="ml-4">
  25. <el-button size="large" type="primary" @click="searchClick">
  26. <HcIcon name="search-2"/>
  27. <span>搜索</span>
  28. </el-button>
  29. </div>
  30. <div class="ml-2">
  31. <el-button size="large" @click="resetClick">
  32. <HcIcon name="close-circle"/>
  33. <span>重置</span>
  34. </el-button>
  35. </div>
  36. </template>
  37. <template #extra>
  38. <el-button size="large" type="primary" hc-btn @click="addRowClick">
  39. <HcIcon name="add"/>
  40. <span>新增计划</span>
  41. </el-button>
  42. </template>
  43. <HcTable :isIndex="false" :column="tableColumn" :datas="tableData" :loading="tableLoading">
  44. <template #key1="{row}">
  45. <span class="text-blue">{{row.key1}}</span>
  46. </template>
  47. <template #key4="{row}">
  48. <span>{{row.key4}}条</span>
  49. </template>
  50. <template #key5="{row}">
  51. <span>{{row.key5}}条</span>
  52. </template>
  53. <template #key6="{row}">
  54. <span>{{row.key6}}条</span>
  55. </template>
  56. <template #action="{row,index}">
  57. <el-button plain size="small" type="primary" @click="editRowClick(row)">编辑</el-button>
  58. <el-button plain size="small" type="danger">删除</el-button>
  59. </template>
  60. </HcTable>
  61. <template #action>
  62. <HcPages :pages="searchForm" @change="pageChange"/>
  63. </template>
  64. </HcCard>
  65. </template>
  66. <script setup>
  67. import {ref} from "vue";
  68. import {useRouter} from 'vue-router'
  69. const router = useRouter()
  70. //计划类型
  71. const planType = ref([
  72. {name: '临时计划', key: '1'},
  73. {name: '月度计划', key: '2'},
  74. {name: '年度计划', key: '3'},
  75. ])
  76. //选择部门
  77. const department = ref([
  78. {name: '研发部门', key: '1'},
  79. {name: '业务部门', key: '2'},
  80. {name: '人事部门', key: '3'},
  81. ])
  82. //搜索表单
  83. const searchForm = ref({
  84. planType: null, startTime: null, endTime: null, department: null, queryValue: '',
  85. current: 1, size: 20, total: 0
  86. })
  87. //搜索框回车
  88. const keyUpEvent = (event) => {
  89. if (event.key === "Enter") {
  90. searchForm.value.current = 1;
  91. getTableData()
  92. }
  93. }
  94. //搜索
  95. const searchClick = () => {
  96. searchForm.value.current = 1;
  97. getTableData()
  98. }
  99. //重置搜索表单
  100. const resetClick = () => {
  101. searchForm.value = {current: 1, size: 20, total: 0}
  102. }
  103. //分页被点击
  104. const pageChange = ({current, size}) => {
  105. searchForm.value.current = current
  106. searchForm.value.size = size
  107. getTableData()
  108. }
  109. //获取数据
  110. const tableLoading = ref(false)
  111. const tableColumn = [
  112. {key: 'key', name: '编号', width: '90', align: 'center'},
  113. {key: 'key1', name: '计划名称'},
  114. {key: 'key2', name: '计划类型', width: '120', align: 'center'},
  115. {key: 'key3', name: '计划起止日期', width: '220', align: 'center'},
  116. {key: 'key4', name: '计划数量', width: '120', align: 'center'},
  117. {key: 'key5', name: '已完成计划', width: '120', align: 'center'},
  118. {key: 'key6', name: '未完成计划', width: '100', align: 'center'},
  119. {key: 'key8', name: '计划制定人', width: '100', align: 'center'},
  120. {key: 'action', name: '操作', width: '130', align: 'center'},
  121. ]
  122. const tableData = ref([
  123. {id: 1, key: 'JH-01', key1: '2023年5月度计划', key2: '临时计划', key3: '2022-07-01~2027-04-12', key4: '36', key5: '30', key6: '6', key8: '张三'},
  124. {id: 2, key: 'JH-01', key1: '2023年5月度计划', key2: '临时计划', key3: '2022-07-01~2027-04-12', key4: '36', key5: '30', key6: '6', key8: '张三'},
  125. {id: 3, key: 'JH-01', key1: '2023年5月度计划', key2: '临时计划', key3: '2022-07-01~2027-04-12', key4: '36', key5: '30', key6: '6', key8: '张三'},
  126. {id: 4, key: 'JH-01', key1: '2023年5月度计划', key2: '临时计划', key3: '2022-07-01~2027-04-12', key4: '36', key5: '30', key6: '6', key8: '张三'},
  127. ])
  128. const getTableData = () => {
  129. }
  130. //新增计划
  131. const addRowClick = () => {
  132. router.push({
  133. name: 'program-index-info'
  134. })
  135. }
  136. //编辑预算
  137. const editRowClick = (row) => {
  138. router.push({
  139. name: 'program-index-info',
  140. query: {
  141. id: row.id
  142. }
  143. })
  144. }
  145. </script>