index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="编码" prop="code">
  5. <el-input
  6. v-model="queryParams.code"
  7. placeholder="请输入编码"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['suport:piont:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. plain
  32. icon="el-icon-edit"
  33. size="mini"
  34. :disabled="single"
  35. @click="handleUpdate"
  36. v-hasPermi="['suport:piont:edit']"
  37. >修改</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="el-icon-delete"
  44. size="mini"
  45. :disabled="multiple"
  46. @click="handleDelete"
  47. v-hasPermi="['suport:piont:remove']"
  48. >删除</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. @click="handleExport"
  57. v-hasPermi="['suport:piont:export']"
  58. >导出</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="primary"
  63. plain
  64. icon="el-icon-upload2"
  65. size="mini"
  66. @click="handleImport"
  67. v-hasPermi="['suport:piont:add']"
  68. >导入</el-button>
  69. </el-col>
  70. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  71. </el-row>
  72. <el-table v-loading="loading" :data="piontList" @selection-change="handleSelectionChange">
  73. <el-table-column type="selection" width="55" align="center" />
  74. <el-table-column label="编码" align="center" prop="code" />
  75. <el-table-column label="检查点" align="center" prop="checkPiont" />
  76. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  77. <template slot-scope="scope">
  78. <el-button
  79. size="mini"
  80. type="text"
  81. icon="el-icon-edit"
  82. @click="handleUpdate(scope.row)"
  83. v-hasPermi="['suport:piont:edit']"
  84. >修改</el-button>
  85. <el-button
  86. size="mini"
  87. type="text"
  88. icon="el-icon-delete"
  89. @click="handleDelete(scope.row)"
  90. v-hasPermi="['suport:piont:remove']"
  91. >删除</el-button>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. <pagination
  96. v-show="total>0"
  97. :total="total"
  98. :page.sync="queryParams.pageNum"
  99. :limit.sync="queryParams.pageSize"
  100. @pagination="getList"
  101. />
  102. <!-- 添加或修改检查点管理对话框 -->
  103. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  104. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  105. <el-form-item label="编码" prop="code">
  106. <el-input v-model="form.code" placeholder="请输入编码" />
  107. </el-form-item>
  108. <el-form-item label="检查点" prop="checkPiont">
  109. <el-input v-model="form.checkPiont" type="textarea" placeholder="请输入内容" />
  110. </el-form-item>
  111. </el-form>
  112. <div slot="footer" class="dialog-footer">
  113. <el-button type="primary" @click="submitForm">确 定</el-button>
  114. <el-button @click="cancel">取 消</el-button>
  115. </div>
  116. </el-dialog>
  117. <!-- 导入检查点 -->
  118. <el-dialog
  119. :title="upload.title"
  120. :visible.sync="upload.open"
  121. width="400px"
  122. append-to-body
  123. :close-on-click-modal="false"
  124. >
  125. <el-upload
  126. ref="upload"
  127. :limit="1"
  128. accept=".xlsx, .xls"
  129. :headers="upload.headers"
  130. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  131. :disabled="upload.isUploading"
  132. :on-progress="handleFileUploadProgress"
  133. :on-success="handleFileSuccess"
  134. :auto-upload="false"
  135. drag
  136. >
  137. <i class="el-icon-upload"></i>
  138. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  139. <div class="el-upload__tip text-center" slot="tip">
  140. <div class="el-upload__tip" slot="tip">
  141. <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据
  142. </div>
  143. <span>仅允许导入xls、xlsx格式文件。</span>
  144. <el-link
  145. type="primary"
  146. :underline="false"
  147. style="font-size: 12px; vertical-align: baseline"
  148. @click="importTemplate"
  149. >下载模板</el-link
  150. >
  151. </div>
  152. </el-upload>
  153. <div slot="footer" class="dialog-footer">
  154. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  155. <el-button @click="upload.open = false">取 消</el-button>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { listPiont, getPiont, delPiont, addPiont, updatePiont } from "@/api/suport/piont";
  162. import { getToken } from "@/utils/auth";
  163. export default {
  164. name: "Piont",
  165. data() {
  166. return {
  167. // 遮罩层
  168. loading: true,
  169. // 选中数组
  170. ids: [],
  171. // 非单个禁用
  172. single: true,
  173. // 非多个禁用
  174. multiple: true,
  175. // 显示搜索条件
  176. showSearch: true,
  177. // 总条数
  178. total: 0,
  179. // 检查点管理表格数据
  180. piontList: [],
  181. // 弹出层标题
  182. title: "",
  183. // 是否显示弹出层
  184. open: false,
  185. // 查询参数
  186. queryParams: {
  187. pageNum: 1,
  188. pageSize: 10,
  189. code: null,
  190. checkPiont: null,
  191. },
  192. // 表单参数
  193. form: {},
  194. // 表单校验
  195. rules: {
  196. },
  197. upload: {
  198. // 是否显示弹出层
  199. open: false,
  200. // 弹出层标题
  201. title: "",
  202. // 是否禁用上传
  203. isUploading: false,
  204. // 是否更新已经存在的用户数据
  205. updateSupport: 0,
  206. // 设置上传的请求头部
  207. headers: { Authorization: "Bearer " + getToken() },
  208. // 上传的地址
  209. url: process.env.VUE_APP_BASE_API + "/suport/piont/importData",
  210. },
  211. };
  212. },
  213. created() {
  214. this.getList();
  215. },
  216. methods: {
  217. /** 查询检查点管理列表 */
  218. getList() {
  219. this.loading = true;
  220. listPiont(this.queryParams).then(response => {
  221. this.piontList = response.rows;
  222. this.total = response.total;
  223. this.loading = false;
  224. });
  225. },
  226. // 取消按钮
  227. cancel() {
  228. this.open = false;
  229. this.reset();
  230. },
  231. // 表单重置
  232. reset() {
  233. this.form = {
  234. id: null,
  235. code: null,
  236. checkPiont: null,
  237. createBy: null,
  238. createTime: null,
  239. updateBy: null,
  240. updateTime: null
  241. };
  242. this.resetForm("form");
  243. },
  244. /** 搜索按钮操作 */
  245. handleQuery() {
  246. this.queryParams.pageNum = 1;
  247. this.getList();
  248. },
  249. /** 重置按钮操作 */
  250. resetQuery() {
  251. this.resetForm("queryForm");
  252. this.handleQuery();
  253. },
  254. // 多选框选中数据
  255. handleSelectionChange(selection) {
  256. this.ids = selection.map(item => item.id)
  257. this.single = selection.length!==1
  258. this.multiple = !selection.length
  259. },
  260. /** 新增按钮操作 */
  261. handleAdd() {
  262. this.reset();
  263. this.open = true;
  264. this.title = "添加检查点管理";
  265. },
  266. /** 修改按钮操作 */
  267. handleUpdate(row) {
  268. this.reset();
  269. const id = row.id || this.ids
  270. getPiont(id).then(response => {
  271. this.form = response.data;
  272. this.open = true;
  273. this.title = "修改检查点管理";
  274. });
  275. },
  276. /** 提交按钮 */
  277. submitForm() {
  278. this.$refs["form"].validate(valid => {
  279. if (valid) {
  280. if (this.form.id != null) {
  281. updatePiont(this.form).then(response => {
  282. this.$modal.msgSuccess("修改成功");
  283. this.open = false;
  284. this.getList();
  285. });
  286. } else {
  287. addPiont(this.form).then(response => {
  288. this.$modal.msgSuccess("新增成功");
  289. this.open = false;
  290. this.getList();
  291. });
  292. }
  293. }
  294. });
  295. },
  296. /** 删除按钮操作 */
  297. handleDelete(row) {
  298. const ids = row.id || this.ids;
  299. this.$modal.confirm('是否确认删除检查点管理编号为"' + ids + '"的数据项?').then(function() {
  300. return delPiont(ids);
  301. }).then(() => {
  302. this.getList();
  303. this.$modal.msgSuccess("删除成功");
  304. }).catch(() => {});
  305. },
  306. /** 导出按钮操作 */
  307. handleExport() {
  308. this.download('suport/piont/export', {
  309. ...this.queryParams
  310. }, `piont_${new Date().getTime()}.xlsx`)
  311. },
  312. /** 导入按钮操作 */
  313. handleImport() {
  314. this.upload.title = "检查点管理";
  315. this.upload.open = true;
  316. },
  317. /** 下载模板操作 */
  318. importTemplate() {
  319. this.download(
  320. "suport/piont/importTemplate",
  321. {},
  322. `检查点管理导入模板.xlsx`
  323. );
  324. },
  325. // 文件上传中处理
  326. handleFileUploadProgress(event, file, fileList) {
  327. this.upload.isUploading = true;
  328. },
  329. // 文件上传成功处理
  330. handleFileSuccess(response, file, fileList) {
  331. this.upload.open = false;
  332. this.upload.isUploading = false;
  333. this.$refs.upload.clearFiles();
  334. this.$alert(
  335. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  336. response.msg +
  337. "</div>",
  338. "导入结果",
  339. { dangerouslyUseHTMLString: true }
  340. );
  341. this.getList();
  342. },
  343. // 提交上传文件
  344. submitFileForm() {
  345. this.$refs.upload.submit();
  346. },
  347. }
  348. };
  349. </script>