index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  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="type" label-width="110">
  5. <el-select v-model="queryParams.deptId" placeholder="请选择综合保税区" clearable filterable class="se">
  6. <el-option v-for="item in deptList" :key="item.id" :label="item.deptName" :value="item.deptId" />
  7. </el-select>
  8. </el-form-item>
  9. <el-form-item label="年份" prop="type" label-width="110">
  10. <!-- <el-select v-model="queryParams.year" placeholder="请选择年份" clearable filterable class="se">
  11. <el-option v-for="item in nearYearList" :key="item" :label="item" :value="item" />
  12. </el-select> -->
  13. <el-date-picker
  14. v-model="queryParams.year"
  15. type="year"
  16. value-format="yyyy"
  17. placeholder="选择年">
  18. </el-date-picker>
  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. v-hasPermi="['rank:RANK:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="el-icon-edit"
  41. size="mini"
  42. :disabled="single"
  43. @click="handleUpdate"
  44. v-hasPermi="['rank:RANK:edit']"
  45. >修改</el-button>
  46. </el-col>
  47. <el-col :span="1.5">
  48. <el-button
  49. type="danger"
  50. plain
  51. icon="el-icon-delete"
  52. size="mini"
  53. :disabled="multiple"
  54. @click="handleDelete"
  55. v-hasPermi="['rank:RANK:remove']"
  56. >删除</el-button>
  57. </el-col>
  58. <el-col :span="1.5">
  59. <el-button
  60. type="warning"
  61. plain
  62. icon="el-icon-download"
  63. size="mini"
  64. @click="handleExport"
  65. v-hasPermi="['rank:RANK:export']"
  66. >导出</el-button>
  67. </el-col>
  68. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  69. </el-row>
  70. <el-table :data="RANKList" @selection-change="handleSelectionChange">
  71. <el-table-column type="selection" width="55" align="center" />
  72. <el-table-column label="综合保税区" align="center" prop="deptName">
  73. <template slot-scope="scope">
  74. {{scope.row.deptName}}
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="年份" align="center" prop="year">
  78. <template slot-scope="scope">
  79. {{scope.row.year}}
  80. </template>
  81. </el-table-column>
  82. <el-table-column label="全国进出口值排名" align="center" prop="ranking">
  83. <template slot-scope="scope">
  84. {{scope.row.ranking == 0 || scope.row.ranking==null?'-':scope.row.ranking}}
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="中西部绩效排名" align="center" prop="midwestRanking">
  88. <template slot-scope="scope">
  89. {{scope.row.midwestRanking==0 || scope.row.midwestRanking==null?'-':scope.row.midwestRanking}}
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="全国绩效排名" align="center" prop="nationalPerformanceRanking">
  93. <template slot-scope="scope">
  94. {{scope.row.nationalPerformanceRanking==0|| scope.row.nationalPerformanceRanking==null?'-':scope.row.nationalPerformanceRanking}}
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  98. <template slot-scope="scope">
  99. <el-button
  100. size="mini"
  101. type="text"
  102. icon="el-icon-edit"
  103. @click="handleUpdate(scope.row)"
  104. v-hasPermi="['rank:RANK:edit']"
  105. >修改</el-button>
  106. <el-button
  107. size="mini"
  108. type="text"
  109. icon="el-icon-delete"
  110. @click="handleDelete(scope.row)"
  111. v-hasPermi="['rank:RANK:remove']"
  112. >删除</el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改广西保税区排名对话框 -->
  124. <el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
  125. <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  126. <el-form-item prop="deptId" label="综合保税区名称">
  127. <el-select v-model="form.deptId" filterable default-first-option clearable placeholder="请选择综合保税区">
  128. <el-option
  129. v-for="item in deptList"
  130. :key="item.deptId"
  131. :label="item.deptName"
  132. :value="item.deptId">
  133. </el-option>
  134. </el-select>
  135. </el-form-item>
  136. <el-form-item prop="year" label="年份">
  137. <el-select v-model="form.year" filterable default-first-option clearable placeholder="请选择年份">
  138. <el-option
  139. v-for="(item,i) in nearYearList"
  140. :key="i"
  141. :label="item"
  142. :value="item">
  143. </el-option>
  144. </el-select>
  145. </el-form-item>
  146. <el-form-item prop="ranking" label="全国进出口值排名">
  147. <el-input v-model="form.ranking" placeholder="请输入排名" ></el-input>
  148. </el-form-item>
  149. <el-form-item prop="midwestRanking" label="中西部绩效排名">
  150. <el-input v-model="form.midwestRanking" placeholder="请输入排名" ></el-input>
  151. </el-form-item>
  152. <el-form-item prop="nationalPerformanceRanking" label="全国绩效排名">
  153. <el-input v-model="form.nationalPerformanceRanking" placeholder="请输入排名" ></el-input>
  154. </el-form-item>
  155. </el-form>
  156. <div slot="footer" class="dialog-footer">
  157. <el-button type="primary" @click="submitForm">确 定</el-button>
  158. <el-button @click="cancel">取 消</el-button>
  159. </div>
  160. </el-dialog>
  161. </div>
  162. </template>
  163. <script>
  164. import { listRANK, getRANK, delRANK, addRANK, updateRANK } from "@/api/rank/RANK";
  165. import { listDept } from '@/api/system/dept'
  166. export default {
  167. name: "RANK",
  168. data() {
  169. return {
  170. // 根路径
  171. baseURL: process.env.VUE_APP_BASE_API,
  172. // 遮罩层
  173. loading: true,
  174. // 选中数组
  175. ids: [],
  176. // 非单个禁用
  177. single: true,
  178. // 非多个禁用
  179. multiple: true,
  180. // 显示搜索条件
  181. showSearch: true,
  182. // 总条数
  183. total: 0,
  184. // 广西保税区排名表格数据
  185. RANKList: [],
  186. // 保税区列表
  187. deptList: [],
  188. // 近年年份列表
  189. nearYearList: [],
  190. // 弹出层标题
  191. title: "",
  192. // 是否显示弹出层
  193. open: false,
  194. // 查询参数
  195. queryParams: {
  196. pageNum: 1,
  197. pageSize: 10,
  198. id: null,
  199. deptId: null,
  200. year: null,
  201. ranking: null,
  202. createTime: null,
  203. createBy: null
  204. },
  205. // 表单参数
  206. form: {},
  207. // 表单校验
  208. rules: {
  209. deptId: [
  210. { required: true, message: "综合保税区ID不能为空", trigger: "blur" }
  211. ],
  212. year: [
  213. { required: true, message: "年份不能为空", trigger: "blur" }
  214. ],
  215. ranking: [
  216. { required: true, message: "全国进出口值排名不能为空", trigger: "blur" },
  217. { trigger: 'blur', validator: this.validateNumber }
  218. ],
  219. midwestRanking: [
  220. { required: true, message: "中西部绩效排名不能为空", trigger: "blur" },
  221. { trigger: 'blur', validator: this.validateNumber }
  222. ],
  223. nationalPerformanceRanking: [
  224. { required: true, message: "全国绩效排名不能为空", trigger: "blur" },
  225. { trigger: 'blur', validator: this.validateNumber }
  226. ]
  227. }
  228. };
  229. },
  230. created() {
  231. this.getList();
  232. },
  233. methods: {
  234. /** 查询广西保税区排名列表 */
  235. getList() {
  236. this.loading = true;
  237. listRANK(this.queryParams).then(response => {
  238. this.RANKList = response.rows;
  239. this.total = response.total;
  240. this.loading = false;
  241. });
  242. this.getDeptList();
  243. this.getNearYear();
  244. },
  245. // 获取保税区列表
  246. getDeptList() {
  247. this.loading = true;
  248. listDept({parentId: '100'}).then(response => {
  249. this.deptList = response.data
  250. this.loading = false;
  251. });
  252. },
  253. // 获取近年年份
  254. getNearYear() {
  255. // let currentDate = new Date();
  256. // let curYear = currentDate.getFullYear();
  257. // // 获取近三年
  258. // let nearYearArr = [];
  259. // nearYearArr.push(curYear)
  260. // for (let i = 1; i <= 10; i++) {
  261. // nearYearArr.push(curYear - i + '');
  262. // }
  263. // this.nearYearList = nearYearArr
  264. },
  265. // 取消按钮
  266. cancel() {
  267. this.open = false;
  268. this.reset();
  269. },
  270. // 表单重置
  271. reset() {
  272. this.form = {
  273. id: null,
  274. deptId: null,
  275. year: null,
  276. ranking: null,
  277. };
  278. this.resetForm("form");
  279. },
  280. /** 搜索按钮操作 */
  281. handleQuery() {
  282. this.queryParams.pageNum = 1;
  283. this.getList();
  284. },
  285. /** 重置按钮操作 */
  286. resetQuery() {
  287. this.queryParams.deptId = '';
  288. this.queryParams.year = '';
  289. this.resetForm("queryForm");
  290. this.handleQuery();
  291. },
  292. // 多选框选中数据
  293. handleSelectionChange(selection) {
  294. this.ids = selection.map(item => item.id)
  295. this.single = selection.length!==1
  296. this.multiple = !selection.length
  297. },
  298. /** 新增按钮操作 */
  299. handleAdd() {
  300. this.reset();
  301. this.open = true;
  302. this.title = "添加广西保税区排名";
  303. },
  304. /** 修改按钮操作 */
  305. handleUpdate(row) {
  306. this.reset();
  307. const id = row.id || this.ids
  308. getRANK(id).then(response => {
  309. this.form = response.data;
  310. this.form.deptId = Number(this.form.deptId)
  311. this.open = true;
  312. this.title = "修改广西保税区排名";
  313. });
  314. },
  315. /** 提交按钮 */
  316. submitForm() {
  317. this.$refs["form"].validate(valid => {
  318. if (valid) {
  319. if (this.form.id != null) {
  320. updateRANK(this.form).then(response => {
  321. this.$modal.msgSuccess("修改成功");
  322. this.open = false;
  323. this.getList();
  324. });
  325. } else {
  326. addRANK(this.form).then(response => {
  327. this.$modal.msgSuccess("新增成功");
  328. this.open = false;
  329. this.getList();
  330. });
  331. }
  332. }
  333. });
  334. },
  335. /** 删除按钮操作 */
  336. handleDelete(row) {
  337. const ids = row.id || this.ids;
  338. this.$modal.confirm('是否确认删除广西保税区排名编号为"' + ids + '"的数据项?').then(function() {
  339. return delRANK(ids);
  340. }).then(() => {
  341. this.getList();
  342. this.$modal.msgSuccess("删除成功");
  343. }).catch(() => {});
  344. },
  345. /** 导出按钮操作 */
  346. handleExport() {
  347. this.download('rank/RANK/export', {
  348. ...this.queryParams
  349. }, `RANK_${new Date().getTime()}.xlsx`)
  350. },
  351. // 校验参数
  352. validateNumber(rule, value, callback) {
  353. if (value === '') {
  354. callback(new Error('请输入整数'));
  355. } else if (!Number.isInteger(Number(value))) {
  356. callback(new Error('请输入整数'));
  357. } else if (Number(value) < 0) {
  358. callback(new Error('不能小于0'));
  359. } else {
  360. callback();
  361. }
  362. }
  363. }
  364. };
  365. </script>