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