Commit f74c9820a76c3e24313d8be42a252018006345d4

Authored by guzijian
1 parent b5257a9a

feat: 修改报表导出按钮

Showing 1 changed file with 40 additions and 9 deletions
src/views/report/sign/index.vue
... ... @@ -28,8 +28,8 @@
28 28 <el-button type="primary" @click="onQuery">查询</el-button>
29 29 </el-form-item>
30 30 <el-form-item>
31   - <el-button type="primary" @click="onExport(1)">导出当前日期</el-button>
32   - <el-button type="primary" @click="onExport(2)">导出当月</el-button>
  31 + <el-button type="primary" @click="onExportDateType('date')">按天导出</el-button>
  32 + <el-button type="primary" @click="onExportDateType('month')">按月导出</el-button>
33 33 </el-form-item>
34 34  
35 35 <el-form-item>
... ... @@ -114,6 +114,16 @@
114 114 <el-table-column label="原因" align="center" fixed="right" prop="remark" width="300" />
115 115 </el-table>
116 116 </el-dialog>
  117 + <el-dialog title="请选择导出日期" v-model="openDateFlag" width="1080px" append-to-body>
  118 + <el-form>
  119 + <el-form-item label="日期">
  120 + <el-date-picker v-model="exportDate" :format="exportFormat == 'month' ? 'YYYY-MM' : 'YYYY-MM-DD'"
  121 + :value-format="exportFormat == 'month' ? 'YYYY-MM' : 'YYYY-MM-DD'" :type="exportFormat"
  122 + placeholder="选择重新生成月份" />
  123 + </el-form-item>
  124 + </el-form>
  125 + <el-button type="primary" @click="onExport()">导出</el-button>
  126 + </el-dialog>
117 127 </div>
118 128 </template>
119 129  
... ... @@ -137,8 +147,9 @@ const total = ref(0); //总条目数
137 147 const pageSizes = [5, 10, 20, 50]; //每页显示多少条
138 148 const tableData = ref([]) // 表格数据
139 149 const currentPage = ref(1) // 当前页
140   -let timer = ref();
141   -
  150 +const exportDate = ref()
  151 +const exportFormat = ref("date")
  152 +const openDateFlag = ref(false)
142 153  
143 154 const rules = ref({
144 155 date: [
... ... @@ -234,17 +245,37 @@ const reset = () =&gt; {
234 245 detailList.value = [];
235 246 }
236 247 // 导出
237   -const onExport = (val) => {
  248 +const onExport = () => {
238 249 // exportReportList({}).then((res) => {
239 250 // console.log(res)
240 251 // } ,`in_${new Date().getTime()}.xlsx`);
241 252 // console.log("导出");
242   - let namePre = val == 1 ? fromParams.value.date : moment(fromParams.value.date).format("YYYY-MM")
  253 + if (!exportDate.value) {
  254 + proxy.$message({
  255 + message: '请选择日期',
  256 + type: 'warning'
  257 + })
  258 + return
  259 + }
  260 + let namePre = exportFormat.value === 'date' ? exportDate.value : exportDate.value + '-01';
  261 + console.log(namePre);
243 262 proxy.download('report/export', {
244 263 ids: ids.value,
245   - date: fromParams.value.date,
246   - exportFlag: val
247   - }, `${namePre}签到报表.xlsx`)
  264 + date: namePre,
  265 + exportFlag: exportFormat.value === 'date' ? 1 : 2
  266 + }, `${exportDate.value}签到报表.xlsx`)
  267 + .then(res => {
  268 + proxy.$message({
  269 + message: '导出成功',
  270 + type: 'success'
  271 + })
  272 + })
  273 +}
  274 +
  275 +const onExportDateType = (val) => {
  276 + openDateFlag.value = true
  277 + exportFormat.value = val
  278 + exportDate.value = ''
248 279 }
249 280 </script>
250 281  
... ...