index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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="attractPlan">
  5. <el-input
  6. v-model="queryParams.attractPlan"
  7. placeholder="请输入招商计划"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="实施计划" prop="implementPlan">
  13. <el-input
  14. v-model="queryParams.implementPlan"
  15. placeholder="请输入实施计划"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="年份" prop="year">
  21. <el-input
  22. v-model="queryParams.year"
  23. placeholder="请输入年份"
  24. clearable
  25. @keyup.enter.native="handleQuery"
  26. />
  27. </el-form-item>
  28. <el-form-item>
  29. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  30. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  31. </el-form-item>
  32. </el-form>
  33. <el-row :gutter="10" class="mb8">
  34. <el-col :span="1.5">
  35. <el-button
  36. type="primary"
  37. plain
  38. icon="el-icon-plus"
  39. size="mini"
  40. @click="handleAdd"
  41. >新增
  42. </el-button>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-button
  46. type="success"
  47. plain
  48. icon="el-icon-edit"
  49. size="mini"
  50. :disabled="single"
  51. @click="handleUpdate"
  52. >修改
  53. </el-button>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-button
  57. type="danger"
  58. plain
  59. icon="el-icon-delete"
  60. size="mini"
  61. :disabled="multiple"
  62. @click="handleDelete"
  63. >删除
  64. </el-button>
  65. </el-col>
  66. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  67. </el-row>
  68. <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
  69. <el-table-column type="selection" width="55" align="center"/>
  70. <el-table-column label="主键id" align="center" prop="id"/>
  71. <el-table-column label="招商计划" align="center" prop="attractPlan"/>
  72. <el-table-column label="实施计划" align="center" prop="implementPlan"/>
  73. <el-table-column label="年份" align="center" prop="year"/>
  74. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  75. <template slot-scope="scope">
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-edit"
  80. @click="handleUpdate(scope.row)"
  81. >修改
  82. </el-button>
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-delete"
  87. @click="handleDelete(scope.row)"
  88. >删除
  89. </el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改服务一汽-招商/实施计划对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="招商计划" prop="attractPlan">
  104. <el-input v-model="form.attractPlan" placeholder="请输入招商计划"/>
  105. </el-form-item>
  106. <el-form-item label="实施计划" prop="implementPlan">
  107. <el-input v-model="form.implementPlan" placeholder="请输入实施计划"/>
  108. </el-form-item>
  109. <el-form-item label="年份" prop="year">
  110. <el-input v-model="form.year" placeholder="请输入年份"/>
  111. </el-form-item>
  112. </el-form>
  113. <div slot="footer" class="dialog-footer">
  114. <el-button type="primary" @click="submitForm">确 定</el-button>
  115. <el-button @click="cancel">取 消</el-button>
  116. </div>
  117. </el-dialog>
  118. </div>
  119. </template>
  120. <script>
  121. import {getPlan, listPlan, addPlan, delPlan, updatePlan} from "@/api/system/plan";
  122. export default {
  123. name: "Plan",
  124. data() {
  125. return {
  126. // 遮罩层
  127. loading: true,
  128. // 选中数组
  129. ids: [],
  130. // 非单个禁用
  131. single: true,
  132. // 非多个禁用
  133. multiple: true,
  134. // 显示搜索条件
  135. showSearch: true,
  136. // 总条数
  137. total: 0,
  138. // 服务一汽-招商/实施计划表格数据
  139. planList: [],
  140. // 弹出层标题
  141. title: "",
  142. // 是否显示弹出层
  143. open: false,
  144. // 查询参数
  145. queryParams: {
  146. pageNum: 1,
  147. pageSize: 10,
  148. attractPlan: null,
  149. implementPlan: null,
  150. year: null
  151. },
  152. // 表单参数
  153. form: {},
  154. // 表单校验
  155. rules: {}
  156. };
  157. },
  158. created() {
  159. this.getList();
  160. },
  161. methods: {
  162. /** 查询服务一汽-招商/实施计划列表 */
  163. getList() {
  164. this.loading = true;
  165. listPlan(this.queryParams).then(response => {
  166. this.planList = response.rows;
  167. this.total = response.total;
  168. this.loading = false;
  169. });
  170. },
  171. // 取消按钮
  172. cancel() {
  173. this.open = false;
  174. this.reset();
  175. },
  176. // 表单重置
  177. reset() {
  178. this.form = {
  179. id: null,
  180. attractPlan: null,
  181. implementPlan: null,
  182. year: null
  183. };
  184. this.resetForm("form");
  185. },
  186. /** 搜索按钮操作 */
  187. handleQuery() {
  188. this.queryParams.pageNum = 1;
  189. this.getList();
  190. },
  191. /** 重置按钮操作 */
  192. resetQuery() {
  193. this.resetForm("queryForm");
  194. this.handleQuery();
  195. },
  196. // 多选框选中数据
  197. handleSelectionChange(selection) {
  198. this.ids = selection.map(item => item.id)
  199. this.single = selection.length !== 1
  200. this.multiple = !selection.length
  201. },
  202. /** 新增按钮操作 */
  203. handleAdd() {
  204. this.reset();
  205. this.open = true;
  206. this.title = "添加服务一汽-招商/实施计划";
  207. },
  208. /** 修改按钮操作 */
  209. handleUpdate(row) {
  210. this.reset();
  211. const id = row.id || this.ids
  212. getPlan(id).then(response => {
  213. this.form = response.data;
  214. this.open = true;
  215. this.title = "修改服务一汽-招商/实施计划";
  216. });
  217. },
  218. /** 提交按钮 */
  219. submitForm() {
  220. this.$refs["form"].validate(valid => {
  221. if (valid) {
  222. if (this.form.id != null) {
  223. updatePlan(this.form).then(response => {
  224. this.$modal.msgSuccess("修改成功");
  225. this.open = false;
  226. this.getList();
  227. });
  228. } else {
  229. addPlan(this.form).then(response => {
  230. this.$modal.msgSuccess("新增成功");
  231. this.open = false;
  232. this.getList();
  233. });
  234. }
  235. }
  236. });
  237. },
  238. /** 删除按钮操作 */
  239. handleDelete(row) {
  240. const ids = row.id || this.ids;
  241. this.$modal.confirm('是否确认删除招商/实施计划为"' + ids + '"的数据项?').then(function () {
  242. return delPlan(ids);
  243. }).then(() => {
  244. this.getList();
  245. this.$modal.msgSuccess("删除成功");
  246. }).catch(() => {
  247. });
  248. },
  249. }
  250. }
  251. ;
  252. </script>