index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="类型" prop="taskType">
  5. <el-select v-model="queryParams.taskType" placeholder="请选择类型" clearable size="small">
  6. <el-option
  7. v-for="dict in taskTypeOptions"
  8. :key="dict.dictValue"
  9. :label="dict.dictLabel"
  10. :value="dict.dictValue"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="状态 " prop="status">
  15. <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  16. <el-option
  17. v-for="dict in statusOptions"
  18. :key="dict.dictValue"
  19. :label="dict.dictLabel"
  20. :value="dict.dictValue"
  21. />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  26. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-row :gutter="10" class="mb8">
  30. <el-col :span="1.5">
  31. <el-button
  32. type="danger"
  33. plain
  34. icon="el-icon-delete"
  35. size="mini"
  36. :disabled="multiple"
  37. @click="handleDelete"
  38. v-hasPermi="['his:exportTask:remove']"
  39. >删除</el-button>
  40. </el-col>
  41. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  42. </el-row>
  43. <el-table border v-loading="loading" :data="exportTaskList" @selection-change="handleSelectionChange">
  44. <el-table-column type="selection" width="55" align="center" />
  45. <el-table-column label="ID" align="center" prop="taskId" />
  46. <el-table-column label="类型" align="center" prop="taskType">
  47. <template slot-scope="scope">
  48. <dict-tag :options="taskTypeOptions" :value="scope.row.taskType"/>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="备注" align="center" prop="remark" />
  52. <el-table-column label="状态" align="center" prop="status">
  53. <template slot-scope="scope">
  54. <dict-tag :options="statusOptions" :value="scope.row.status"/>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="文件地址" align="center" prop="fileUrl" />
  58. <el-table-column label="开始时间" align="center" prop="startTime" />
  59. <el-table-column label="结束时间" align="center" prop="finishTime" />
  60. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  61. <template slot-scope="scope">
  62. <el-button
  63. size="mini"
  64. type="text"
  65. icon="el-icon-edit"
  66. @click="handleUpdate(scope.row)"
  67. v-hasPermi="['his:exportTask:edit']"
  68. >下载</el-button>
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-delete"
  73. @click="handleDelete(scope.row)"
  74. v-hasPermi="['his:exportTask:remove']"
  75. >删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <pagination
  80. v-show="total>0"
  81. :total="total"
  82. :page.sync="queryParams.pageNum"
  83. :limit.sync="queryParams.pageSize"
  84. @pagination="getList"
  85. />
  86. <!-- 添加或修改导出任务对话框 -->
  87. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  88. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  89. <el-form-item label="类型" prop="taskType">
  90. <el-select v-model="form.taskType" placeholder="请选择类型">
  91. <el-option
  92. v-for="dict in taskTypeOptions"
  93. :key="dict.dictValue"
  94. :label="dict.dictLabel"
  95. :value="parseInt(dict.dictValue)"
  96. ></el-option>
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item label="天始时间" prop="startTime">
  100. <el-date-picker clearable size="small"
  101. v-model="form.startTime"
  102. type="date"
  103. value-format="yyyy-MM-dd"
  104. placeholder="选择天始时间">
  105. </el-date-picker>
  106. </el-form-item>
  107. <el-form-item label="结束时间" prop="finishTime">
  108. <el-date-picker clearable size="small"
  109. v-model="form.finishTime"
  110. type="date"
  111. value-format="yyyy-MM-dd"
  112. placeholder="选择结束时间">
  113. </el-date-picker>
  114. </el-form-item>
  115. <el-form-item label="备注" prop="remark">
  116. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  117. </el-form-item>
  118. <el-form-item label="状态 0 导出 1 成功 2 失败 ">
  119. <el-radio-group v-model="form.status">
  120. <el-radio
  121. v-for="dict in statusOptions"
  122. :key="dict.dictValue"
  123. :label="parseInt(dict.dictValue)"
  124. >{{dict.dictLabel}}</el-radio>
  125. </el-radio-group>
  126. </el-form-item>
  127. <el-form-item label="文件地址" prop="fileUrl">
  128. <el-input v-model="form.fileUrl" placeholder="请输入文件地址" />
  129. </el-form-item>
  130. <el-form-item label="系统类型 1 总后台 2 销售后台" prop="sysType">
  131. <el-select v-model="form.sysType" placeholder="请选择系统类型 1 总后台 2 销售后台">
  132. <el-option
  133. v-for="dict in sysTypeOptions"
  134. :key="dict.dictValue"
  135. :label="dict.dictLabel"
  136. :value="parseInt(dict.dictValue)"
  137. ></el-option>
  138. </el-select>
  139. </el-form-item>
  140. <el-form-item label="用户id" prop="userId">
  141. <el-input v-model="form.userId" placeholder="请输入用户id" />
  142. </el-form-item>
  143. <el-form-item label="销售id" prop="companyUserId">
  144. <el-input v-model="form.companyUserId" placeholder="请输入销售id" />
  145. </el-form-item>
  146. </el-form>
  147. <div slot="footer" class="dialog-footer">
  148. <el-button type="primary" @click="submitForm">确 定</el-button>
  149. <el-button @click="cancel">取 消</el-button>
  150. </div>
  151. </el-dialog>
  152. </div>
  153. </template>
  154. <script>
  155. import { listExportTask, getExportTask, delExportTask, addExportTask, updateExportTask, exportExportTask } from "@/api/store/exportTask";
  156. export default {
  157. name: "ExportTask",
  158. data() {
  159. return {
  160. // 遮罩层
  161. loading: true,
  162. // 导出遮罩层
  163. exportLoading: false,
  164. // 选中数组
  165. ids: [],
  166. // 非单个禁用
  167. single: true,
  168. // 非多个禁用
  169. multiple: true,
  170. // 显示搜索条件
  171. showSearch: true,
  172. // 总条数
  173. total: 0,
  174. // 导出任务表格数据
  175. exportTaskList: [],
  176. // 弹出层标题
  177. title: "",
  178. // 是否显示弹出层
  179. open: false,
  180. // 类型 1帐单记录字典
  181. taskTypeOptions: [],
  182. // 状态 0 导出 1 成功 2 失败 字典
  183. statusOptions: [],
  184. // 系统类型 1 总后台 2 销售后台字典
  185. sysTypeOptions: [],
  186. // 查询参数
  187. queryParams: {
  188. pageNum: 1,
  189. pageSize: 10,
  190. taskType: null,
  191. startTime: null,
  192. finishTime: null,
  193. status: null,
  194. fileUrl: null,
  195. sysType: null,
  196. userId: null,
  197. companyUserId: null
  198. },
  199. // 表单参数
  200. form: {},
  201. // 表单校验
  202. rules: {
  203. }
  204. };
  205. },
  206. created() {
  207. this.getList();
  208. this.getDicts("sys_export_task_type").then(response => {
  209. this.taskTypeOptions = response.data;
  210. });
  211. this.getDicts("sys_export_task_status").then(response => {
  212. this.statusOptions = response.data;
  213. });
  214. this.getDicts("sys_type").then(response => {
  215. this.sysTypeOptions = response.data;
  216. });
  217. },
  218. methods: {
  219. /** 查询导出任务列表 */
  220. getList() {
  221. this.loading = true;
  222. listExportTask(this.queryParams).then(response => {
  223. this.exportTaskList = response.rows;
  224. this.total = response.total;
  225. this.loading = false;
  226. });
  227. },
  228. // 取消按钮
  229. cancel() {
  230. this.open = false;
  231. this.reset();
  232. },
  233. // 表单重置
  234. reset() {
  235. this.form = {
  236. taskId: null,
  237. taskType: null,
  238. startTime: null,
  239. finishTime: null,
  240. remark: null,
  241. status: 0,
  242. fileUrl: null,
  243. sysType: null,
  244. userId: null,
  245. companyUserId: null
  246. };
  247. this.resetForm("form");
  248. },
  249. /** 搜索按钮操作 */
  250. handleQuery() {
  251. this.queryParams.pageNum = 1;
  252. this.getList();
  253. },
  254. /** 重置按钮操作 */
  255. resetQuery() {
  256. this.resetForm("queryForm");
  257. this.handleQuery();
  258. },
  259. // 多选框选中数据
  260. handleSelectionChange(selection) {
  261. this.ids = selection.map(item => item.taskId)
  262. this.single = selection.length!==1
  263. this.multiple = !selection.length
  264. },
  265. /** 新增按钮操作 */
  266. handleAdd() {
  267. this.reset();
  268. this.open = true;
  269. this.title = "添加导出任务";
  270. },
  271. /** 修改按钮操作 */
  272. handleUpdate(row) {
  273. this.download(row.fileUrl);
  274. },
  275. /** 提交按钮 */
  276. submitForm() {
  277. this.$refs["form"].validate(valid => {
  278. if (valid) {
  279. if (this.form.taskId != null) {
  280. updateExportTask(this.form).then(response => {
  281. this.msgSuccess("修改成功");
  282. this.open = false;
  283. this.getList();
  284. });
  285. } else {
  286. addExportTask(this.form).then(response => {
  287. this.msgSuccess("新增成功");
  288. this.open = false;
  289. this.getList();
  290. });
  291. }
  292. }
  293. });
  294. },
  295. /** 删除按钮操作 */
  296. handleDelete(row) {
  297. const taskIds = row.taskId || this.ids;
  298. this.$confirm('是否确认删除导出任务编号为"' + taskIds + '"的数据项?', "警告", {
  299. confirmButtonText: "确定",
  300. cancelButtonText: "取消",
  301. type: "warning"
  302. }).then(function() {
  303. return delExportTask(taskIds);
  304. }).then(() => {
  305. this.getList();
  306. this.msgSuccess("删除成功");
  307. }).catch(() => {});
  308. },
  309. /** 导出按钮操作 */
  310. handleExport() {
  311. const queryParams = this.queryParams;
  312. this.$confirm('是否确认导出所有导出任务数据项?', "警告", {
  313. confirmButtonText: "确定",
  314. cancelButtonText: "取消",
  315. type: "warning"
  316. }).then(() => {
  317. this.exportLoading = true;
  318. return exportExportTask(queryParams);
  319. }).then(response => {
  320. this.download(response.msg);
  321. this.exportLoading = false;
  322. }).catch(() => {});
  323. }
  324. }
  325. };
  326. </script>