index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  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="companyName">
  5. <el-input
  6. v-model="queryParams.companyName"
  7. placeholder="请输入企业名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="监控人员" prop="monitorByName">
  13. <el-input
  14. v-model="queryParams.monitorByName"
  15. placeholder="请输入监控人员名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <BatchImport
  28. ref="batchImport"
  29. @import="handelImport"
  30. @temDownload="handleTemDownload"
  31. :fileSize="1"></BatchImport>
  32. </el-col>
  33. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  34. </el-row>
  35. <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
  36. <el-table-column type="selection" width="55" align="center" />
  37. <el-table-column label="企业名称" align="center" prop="companyName" />
  38. <el-table-column label="监控人员" align="center" prop="monitorByName" />
  39. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  40. <template slot-scope="scope">
  41. <el-button
  42. size="mini"
  43. type="text"
  44. icon="el-icon-edit"
  45. @click="handleUpdate(scope.row)"
  46. v-hasPermi="['ctyc:info:edit']"
  47. >修改</el-button>
  48. <el-button
  49. size="mini"
  50. type="text"
  51. icon="el-icon-delete"
  52. @click="handleDelete(scope.row)"
  53. v-hasPermi="['ctyc:info:remove']"
  54. >删除</el-button>
  55. </template>
  56. </el-table-column>
  57. </el-table>
  58. <pagination
  59. v-show="total>0"
  60. :total="total"
  61. :page.sync="queryParams.pageNum"
  62. :limit.sync="queryParams.pageSize"
  63. @pagination="getList"
  64. />
  65. <!--修改合作企业对话框 -->
  66. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  67. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  68. <el-form-item label="企业名称" prop="companyName">
  69. <el-input v-model="form.companyName" disabled="true" />
  70. </el-form-item>
  71. <el-form-item label="监控人员名称" prop="monitorByName">
  72. <el-input v-model="form.monitorByName" placeholder="请输入监控人员名称" />
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="primary" @click="submitForm">确 定</el-button>
  77. <el-button @click="cancel">取 消</el-button>
  78. </div>
  79. </el-dialog>
  80. </div>
  81. </template>
  82. <script>
  83. import { listInfo, getInfo, delInfo, addInfo, updateInfo, fileImport } from "@/api/ctyc/info";
  84. export default {
  85. name: "Info",
  86. components: {
  87. BatchImport: () => import("@/components/BatchImport/indexa.vue"),
  88. },
  89. data() {
  90. return {
  91. // 遮罩层
  92. loading: true,
  93. // 选中数组
  94. ids: [],
  95. // 非单个禁用
  96. single: true,
  97. // 非多个禁用
  98. multiple: true,
  99. // 显示搜索条件
  100. showSearch: true,
  101. // 总条数
  102. total: 0,
  103. // 合作企业表格数据
  104. infoList: [],
  105. // 弹出层标题
  106. title: "",
  107. // 是否显示弹出层
  108. open: false,
  109. // 查询参数
  110. queryParams: {
  111. pageNum: 1,
  112. pageSize: 10,
  113. companyId: null,
  114. companyName: null,
  115. newCompanyName: null,
  116. monitorBy: null,
  117. monitorByName: null,
  118. revision: null,
  119. tenantId: null,
  120. approvalLevel: null,
  121. approvalRemark: null,
  122. approvalBy: null,
  123. approvalByName: null,
  124. approvalTime: null
  125. },
  126. // 表单参数
  127. form: {},
  128. // 表单校验
  129. rules: {
  130. }
  131. };
  132. },
  133. created() {
  134. this.getList();
  135. },
  136. methods: {
  137. // 确认导入
  138. handelImport(fileList) {
  139. this.$modal.loading("加载中...");
  140. let formData = new FormData();
  141. formData.append("file", fileList[0].raw);
  142. fileImport(formData).then((res) => {
  143. if (res.code == 200) {
  144. this.$modal.closeLoading();
  145. this.$notify({
  146. message: res.msg,
  147. type: res.code == 200 ? "success" : "warning",
  148. });
  149. let { setVisible } = this.$refs.batchImport;
  150. setVisible(false);
  151. this.getList();
  152. }
  153. });
  154. },
  155. // 模板下载
  156. handleTemDownload() {
  157. this.download("/ctyc/info/download", {}, `合作企业.xlsx`);
  158. },
  159. /** 查询合作企业列表 */
  160. getList() {
  161. this.loading = true;
  162. listInfo(this.queryParams).then(response => {
  163. this.infoList = response.rows;
  164. this.total = response.total;
  165. this.loading = false;
  166. });
  167. },
  168. // 取消按钮
  169. cancel() {
  170. this.open = false;
  171. this.reset();
  172. },
  173. // 表单重置
  174. reset() {
  175. this.form = {
  176. id: null,
  177. companyId: null,
  178. companyName: null,
  179. newCompanyName: null,
  180. monitorBy: null,
  181. monitorByName: null,
  182. revision: null,
  183. createBy: null,
  184. createTime: null,
  185. updateBy: null,
  186. updateTime: null,
  187. delFlag: null,
  188. tenantId: null,
  189. approvalLevel: null,
  190. approvalRemark: null,
  191. approvalBy: null,
  192. approvalByName: null,
  193. approvalTime: null
  194. };
  195. this.resetForm("form");
  196. },
  197. /** 搜索按钮操作 */
  198. handleQuery() {
  199. this.queryParams.pageNum = 1;
  200. this.getList();
  201. },
  202. /** 重置按钮操作 */
  203. resetQuery() {
  204. this.resetForm("queryForm");
  205. this.handleQuery();
  206. },
  207. // 多选框选中数据
  208. handleSelectionChange(selection) {
  209. this.ids = selection.map(item => item.id)
  210. this.single = selection.length!==1
  211. this.multiple = !selection.length
  212. },
  213. /** 新增按钮操作 */
  214. handleAdd() {
  215. this.reset();
  216. this.open = true;
  217. this.title = "添加合作企业";
  218. },
  219. /** 修改按钮操作 */
  220. handleUpdate(row) {
  221. this.reset();
  222. const id = row.id || this.ids
  223. getInfo(id).then(response => {
  224. this.form = response.data;
  225. this.open = true;
  226. this.title = "修改合作企业";
  227. });
  228. },
  229. /** 提交按钮 */
  230. submitForm() {
  231. this.$refs["form"].validate(valid => {
  232. if (valid) {
  233. if (this.form.id != null) {
  234. updateInfo(this.form).then(response => {
  235. this.$modal.msgSuccess("修改成功");
  236. this.open = false;
  237. this.getList();
  238. });
  239. } else {
  240. addInfo(this.form).then(response => {
  241. this.$modal.msgSuccess("新增成功");
  242. this.open = false;
  243. this.getList();
  244. });
  245. }
  246. }
  247. });
  248. },
  249. /** 删除按钮操作 */
  250. handleDelete(row) {
  251. const ids = row.id || this.ids;
  252. this.$modal.confirm('是否确认删除合作企业编号为"' + ids + '"的数据项?').then(function() {
  253. return delInfo(ids);
  254. }).then(() => {
  255. this.getList();
  256. this.$modal.msgSuccess("删除成功");
  257. }).catch(() => {});
  258. },
  259. /** 导出按钮操作 */
  260. handleExport() {
  261. this.download('ctyc/info/export', {
  262. ...this.queryParams
  263. }, `info_${new Date().getTime()}.xlsx`)
  264. }
  265. }
  266. };
  267. </script>