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,8 +28,8 @@
28 <el-button type="primary" @click="onQuery">查询</el-button> 28 <el-button type="primary" @click="onQuery">查询</el-button>
29 </el-form-item> 29 </el-form-item>
30 <el-form-item> 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 </el-form-item> 33 </el-form-item>
34 34
35 <el-form-item> 35 <el-form-item>
@@ -114,6 +114,16 @@ @@ -114,6 +114,16 @@
114 <el-table-column label="原因" align="center" fixed="right" prop="remark" width="300" /> 114 <el-table-column label="原因" align="center" fixed="right" prop="remark" width="300" />
115 </el-table> 115 </el-table>
116 </el-dialog> 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 </div> 127 </div>
118 </template> 128 </template>
119 129
@@ -137,8 +147,9 @@ const total = ref(0); //总条目数 @@ -137,8 +147,9 @@ const total = ref(0); //总条目数
137 const pageSizes = [5, 10, 20, 50]; //每页显示多少条 147 const pageSizes = [5, 10, 20, 50]; //每页显示多少条
138 const tableData = ref([]) // 表格数据 148 const tableData = ref([]) // 表格数据
139 const currentPage = ref(1) // 当前页 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 const rules = ref({ 154 const rules = ref({
144 date: [ 155 date: [
@@ -234,17 +245,37 @@ const reset = () =&gt; { @@ -234,17 +245,37 @@ const reset = () =&gt; {
234 detailList.value = []; 245 detailList.value = [];
235 } 246 }
236 // 导出 247 // 导出
237 -const onExport = (val) => { 248 +const onExport = () => {
238 // exportReportList({}).then((res) => { 249 // exportReportList({}).then((res) => {
239 // console.log(res) 250 // console.log(res)
240 // } ,`in_${new Date().getTime()}.xlsx`); 251 // } ,`in_${new Date().getTime()}.xlsx`);
241 // console.log("导出"); 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 proxy.download('report/export', { 262 proxy.download('report/export', {
244 ids: ids.value, 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 </script> 280 </script>
250 281