index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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="enterpriseName">
  5. <el-input
  6. v-model="queryParams.enterpriseName"
  7. placeholder="请输入单位名称"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="联系人" prop="inCharge">
  13. <el-input
  14. v-model="queryParams.inCharge"
  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. <el-button
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. >新增</el-button>
  34. </el-col>
  35. <el-col :span="1.5">
  36. <el-button
  37. type="success"
  38. plain
  39. icon="el-icon-edit"
  40. size="mini"
  41. :disabled="single"
  42. @click="handleUpdate"
  43. >修改</el-button>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-button
  47. type="danger"
  48. plain
  49. icon="el-icon-delete"
  50. size="mini"
  51. :disabled="multiple"
  52. @click="handleDelete"
  53. >删除</el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="warning"
  58. plain
  59. icon="el-icon-download"
  60. size="mini"
  61. @click="handleExport"
  62. >导出</el-button>
  63. </el-col>
  64. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  65. </el-row>
  66. <el-table v-loading="loading" :data="enterpriseList" @selection-change="handleSelectionChange">
  67. <el-table-column type="selection" width="55" align="center" />
  68. <el-table-column label="主键" align="center" prop="id" />
  69. <el-table-column label="单位名称" align="center" prop="enterpriseName" />
  70. <el-table-column label="行程名称" align="center" prop="tripName" />
  71. <el-table-column label="联系方式" align="center" prop="tel" />
  72. <el-table-column label="联系人" align="center" prop="inCharge" />
  73. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  74. <template slot-scope="scope">
  75. <el-button
  76. size="mini"
  77. type="text"
  78. icon="el-icon-edit"
  79. @click="handleUpdate(scope.row)"
  80. >修改</el-button>
  81. <el-button
  82. size="mini"
  83. type="text"
  84. icon="el-icon-delete"
  85. @click="handleDelete(scope.row)"
  86. >删除</el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. <pagination
  91. v-show="total>0"
  92. :total="total"
  93. :page.sync="queryParams.pageNum"
  94. :limit.sync="queryParams.pageSize"
  95. @pagination="getList"
  96. />
  97. <!-- 添加或修改cps_meeting_enterprise 与会企业对话框 -->
  98. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  99. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  100. <el-form-item label="单位名称" prop="enterpriseName">
  101. <el-input v-model="form.enterpriseName" placeholder="请输入单位名称" />
  102. </el-form-item>
  103. <el-form-item label="联系方式" prop="tel">
  104. <el-input v-model="form.tel" placeholder="请输入联系方式" />
  105. </el-form-item>
  106. <el-form-item label="联系人" prop="inCharge">
  107. <el-input v-model="form.inCharge" placeholder="请输入联系人" />
  108. </el-form-item>
  109. <el-form-item label="单位行程" prop="tripId">
  110. <el-select v-model="form.tripId" placeholder="请选单位行程">
  111. <el-option
  112. v-for="dict in tripList"
  113. :key="dict.id"
  114. :label="dict.tripName"
  115. :value="parseInt(dict.id)"
  116. ></el-option>
  117. </el-select>
  118. </el-form-item>
  119. </el-form>
  120. <div slot="footer" class="dialog-footer">
  121. <el-button type="primary" @click="submitForm">确 定</el-button>
  122. <el-button @click="cancel">取 消</el-button>
  123. </div>
  124. </el-dialog>
  125. </div>
  126. </template>
  127. <script>
  128. import { addEnterprise, delEnterprise, getEnterprise, listEnterprise, updateEnterprise } from '@/api/cp/enterprise';
  129. import { listEnterpriseTripInfo } from '@/api/cp/enterpriseTripInfo';
  130. export default {
  131. name: "Enterprise",
  132. data() {
  133. return {
  134. // 遮罩层
  135. loading: true,
  136. // 选中数组
  137. ids: [],
  138. // 非单个禁用
  139. single: true,
  140. // 非多个禁用
  141. multiple: true,
  142. // 显示搜索条件
  143. showSearch: true,
  144. // 总条数
  145. total: 0,
  146. // cps_meeting_enterprise 与会企业表格数据
  147. enterpriseList: [],
  148. // 弹出层标题
  149. title: "",
  150. // 是否显示弹出层
  151. open: false,
  152. // 查询参数
  153. queryParams: {
  154. pageNum: 1,
  155. pageSize: 10,
  156. enterpriseName: null,
  157. inCharge: null,
  158. },
  159. // 表单参数
  160. form: {},
  161. // 表单校验
  162. rules: {
  163. enterpriseName: [
  164. { required: true, message: "单位名称不能为空", trigger: "blur" }
  165. ],
  166. tripId: [
  167. { required: true, message: "单位行程不能为空", trigger: "change" }
  168. ],
  169. },
  170. tripList: [],
  171. };
  172. },
  173. created() {
  174. this.getList();
  175. this.getTrip();
  176. },
  177. methods: {
  178. /** 查询cps_meeting_enterprise 与会企业列表 */
  179. getList() {
  180. this.loading = true;
  181. listEnterprise(this.queryParams).then(response => {
  182. this.enterpriseList = response.rows;
  183. this.total = response.total;
  184. this.loading = false;
  185. });
  186. },
  187. // 取消按钮
  188. cancel() {
  189. this.open = false;
  190. this.reset();
  191. },
  192. // 表单重置
  193. reset() {
  194. this.form = {
  195. id: null,
  196. enterpriseName: null,
  197. tel: null,
  198. inCharge: null,
  199. tripId: null,
  200. updateTime: null,
  201. createTime: null,
  202. createBy: null,
  203. updateBy: null
  204. };
  205. this.resetForm("form");
  206. },
  207. /** 搜索按钮操作 */
  208. handleQuery() {
  209. this.queryParams.pageNum = 1;
  210. this.getList();
  211. },
  212. /** 重置按钮操作 */
  213. resetQuery() {
  214. this.resetForm("queryForm");
  215. this.handleQuery();
  216. },
  217. // 多选框选中数据
  218. handleSelectionChange(selection) {
  219. this.ids = selection.map(item => item.id)
  220. this.single = selection.length!==1
  221. this.multiple = !selection.length
  222. },
  223. /** 新增按钮操作 */
  224. handleAdd() {
  225. this.reset();
  226. this.open = true;
  227. this.title = "添加与会单位";
  228. },
  229. /** 修改按钮操作 */
  230. handleUpdate(row) {
  231. this.reset();
  232. const id = row.id || this.ids
  233. getEnterprise(id).then(response => {
  234. this.form = response.data;
  235. this.open = true;
  236. this.title = "修改与会单位";
  237. });
  238. },
  239. /** 提交按钮 */
  240. submitForm() {
  241. this.$refs["form"].validate(valid => {
  242. if (valid) {
  243. if (this.form.id != null) {
  244. updateEnterprise(this.form).then(response => {
  245. this.$modal.msgSuccess("修改成功");
  246. this.open = false;
  247. this.getList();
  248. });
  249. } else {
  250. addEnterprise(this.form).then(response => {
  251. this.$modal.msgSuccess("新增成功");
  252. this.open = false;
  253. this.getList();
  254. });
  255. }
  256. }
  257. });
  258. },
  259. /** 删除按钮操作 */
  260. handleDelete(row) {
  261. const ids = row.id || this.ids;
  262. this.$modal.confirm('是否确认删除与会单位编号为"' + ids + '"的数据项?').then(function() {
  263. return delEnterprise(ids);
  264. }).then(() => {
  265. this.getList();
  266. this.$modal.msgSuccess("删除成功");
  267. }).catch(() => {});
  268. },
  269. /** 导出按钮操作 */
  270. handleExport() {
  271. this.download('cp/enterprise/export', {
  272. ...this.queryParams
  273. }, `enterprise_${new Date().getTime()}.xlsx`)
  274. },
  275. getTrip() {
  276. listEnterpriseTripInfo({
  277. pageNum: 1,
  278. pageSize: 1000,
  279. }).then(response => {
  280. this.tripList = response.rows;
  281. });
  282. }
  283. }
  284. };
  285. </script>