| | |
| | | v-model="daterangeCreateTime" |
| | | size="small" |
| | | style="width: 240px" |
| | | value-format="yyyy-MM-dd" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | type="daterange" |
| | | range-separator="-" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | :default-time="['00:00:00', '23:59:59']" |
| | | ></el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> |
| | | <el-button type="primary" icon="el-icon-search" size="mini" @click="handlePage">搜索(自定义分页接口)</el-button> |
| | | <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="info" |
| | | plain |
| | | icon="el-icon-upload2" |
| | | size="mini" |
| | | @click="handleImport" |
| | | v-hasPermi="['demo:demo:import']" |
| | | >导入(校验)</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button |
| | | type="warning" |
| | | plain |
| | | icon="el-icon-download" |
| | | size="mini" |
| | | :loading="exportLoading" |
| | | @click="handleExport" |
| | | v-hasPermi="['demo:demo:export']" |
| | | >导出</el-button> |
| | |
| | | <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="创建人" align="center" prop="createBy" /> |
| | | <el-table-column label="创建人" align="center" prop="createByName" /> |
| | | <el-table-column label="更新时间" align="center" prop="updateTime" width="180"> |
| | | <template slot-scope="scope"> |
| | | <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column label="更新人" align="center" prop="updateBy" /> |
| | | <el-table-column label="更新人" align="center" prop="updateByName" /> |
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> |
| | | <template slot-scope="scope"> |
| | | <el-button |
| | |
| | | <el-button @click="cancel">取 消</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!-- 用户导入对话框 --> |
| | | <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body> |
| | | <el-upload |
| | | ref="upload" |
| | | :limit="1" |
| | | accept=".xlsx, .xls" |
| | | :headers="upload.headers" |
| | | :action="upload.url + '?updateSupport=' + upload.updateSupport" |
| | | :disabled="upload.isUploading" |
| | | :on-progress="handleFileUploadProgress" |
| | | :on-success="handleFileSuccess" |
| | | :auto-upload="false" |
| | | drag |
| | | > |
| | | <i class="el-icon-upload"></i> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | </el-upload> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="primary" @click="submitFileForm">确 定</el-button> |
| | | <el-button @click="upload.open = false">取 消</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { listDemo, getDemo, delDemo, addDemo, updateDemo, exportDemo } from "@/api/demo/demo"; |
| | | import { listDemo, pageDemo, getDemo, delDemo, addDemo, updateDemo } from "@/api/demo/demo"; |
| | | import {getToken} from "@/utils/auth"; |
| | | |
| | | export default { |
| | | name: "Demo", |
| | |
| | | buttonLoading: false, |
| | | // 遮罩层 |
| | | loading: true, |
| | | // 导出遮罩层 |
| | | exportLoading: false, |
| | | // 选中数组 |
| | | ids: [], |
| | | // 非单个禁用 |
| | |
| | | open: false, |
| | | // 创建时间时间范围 |
| | | daterangeCreateTime: [], |
| | | // 用户导入参数 |
| | | upload: { |
| | | // 是否显示弹出层(用户导入) |
| | | open: false, |
| | | // 弹出层标题(用户导入) |
| | | title: "", |
| | | // 是否禁用上传 |
| | | isUploading: false, |
| | | // 设置上传的请求头部 |
| | | headers: { Authorization: "Bearer " + getToken() }, |
| | | // 上传的地址 |
| | | url: process.env.VUE_APP_BASE_API + "/demo/demo/importData" |
| | | }, |
| | | // 查询参数 |
| | | queryParams: { |
| | | pageNum: 1, |
| | |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** 自定义分页查询 */ |
| | | getPage() { |
| | | this.loading = true; |
| | | this.queryParams.params = {}; |
| | | if (null != this.daterangeCreateTime && '' != this.daterangeCreateTime) { |
| | | this.queryParams.params["beginCreateTime"] = this.daterangeCreateTime[0]; |
| | | this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1]; |
| | | } |
| | | pageDemo(this.queryParams).then(response => { |
| | | this.demoList = response.rows; |
| | | this.total = response.total; |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | // 取消按钮 |
| | | cancel() { |
| | | this.open = false; |
| | |
| | | handleQuery() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getList(); |
| | | }, |
| | | /** 搜索按钮操作 */ |
| | | handlePage() { |
| | | this.queryParams.pageNum = 1; |
| | | this.getPage(); |
| | | }, |
| | | /** 重置按钮操作 */ |
| | | resetQuery() { |
| | |
| | | this.buttonLoading = true; |
| | | if (this.form.id != null) { |
| | | updateDemo(this.form).then(response => { |
| | | this.buttonLoading = false; |
| | | this.msgSuccess("修改成功"); |
| | | this.$modal.msgSuccess("修改成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } else { |
| | | addDemo(this.form).then(response => { |
| | | this.buttonLoading = false; |
| | | this.msgSuccess("新增成功"); |
| | | this.$modal.msgSuccess("新增成功"); |
| | | this.open = false; |
| | | this.getList(); |
| | | }).finally(() => { |
| | | this.buttonLoading = false; |
| | | }); |
| | | } |
| | | } |
| | |
| | | /** 删除按钮操作 */ |
| | | handleDelete(row) { |
| | | const ids = row.id || this.ids; |
| | | this.$confirm('是否确认删除测试单表编号为"' + ids + '"的数据项?', "警告", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.$modal.confirm('是否确认删除测试单表编号为"' + ids + '"的数据项?').then(() => { |
| | | this.loading = true; |
| | | return delDemo(ids); |
| | | }).then(() => { |
| | | this.loading = false; |
| | | this.getList(); |
| | | this.msgSuccess("删除成功"); |
| | | }) |
| | | this.$modal.msgSuccess("删除成功"); |
| | | }).finally(() => { |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** 导入按钮操作 */ |
| | | handleImport() { |
| | | this.upload.title = "用户导入"; |
| | | this.upload.open = true; |
| | | }, |
| | | /** 导出按钮操作 */ |
| | | handleExport() { |
| | | const queryParams = this.queryParams; |
| | | this.$confirm('是否确认导出所有测试单表数据项?', "警告", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }).then(() => { |
| | | this.exportLoading = true; |
| | | return exportDemo(queryParams); |
| | | }).then(response => { |
| | | this.download(response.msg); |
| | | this.exportLoading = false; |
| | | }) |
| | | this.download('demo/demo/export', { |
| | | ...this.queryParams |
| | | }, `demo_${new Date().getTime()}.xlsx`) |
| | | }, |
| | | // 文件上传中处理 |
| | | handleFileUploadProgress(event, file, fileList) { |
| | | this.upload.isUploading = true; |
| | | }, |
| | | // 文件上传成功处理 |
| | | handleFileSuccess(response, file, fileList) { |
| | | this.upload.open = false; |
| | | this.upload.isUploading = false; |
| | | this.$refs.upload.clearFiles(); |
| | | this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true }); |
| | | this.getList(); |
| | | }, |
| | | // 提交上传文件 |
| | | submitFileForm() { |
| | | this.$refs.upload.submit(); |
| | | } |
| | | } |
| | | }; |