index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <!-- 币别及汇率 -->
  2. <template>
  3. <div>
  4. <basic-container v-show="isShow" class="page-crad">
  5. <avue-crud ref="crud" :option="option" :data="dataList" :before-open="beforeOpen" id="out-table"
  6. :header-cell-class-name="headerClassName" :page.sync="page" :search.sync="search" @search-change="searchChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  8. :table-loading="loading" @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 305)"
  9. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 305)" @selection-change="selectionChange"
  10. :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
  11. <template slot="code" slot-scope="scope">
  12. <avue-text-ellipsis :text="scope.row.code" :height="30" use-tooltip placement="top">
  13. <small slot="more">...</small>
  14. </avue-text-ellipsis>
  15. </template>
  16. <template slot="cnName" slot-scope="scope">
  17. <avue-text-ellipsis :text="scope.row.cnName" :height="30" use-tooltip placement="top">
  18. <small slot="more">...</small>
  19. </avue-text-ellipsis>
  20. </template>
  21. <template slot="enName" slot-scope="scope">
  22. <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
  23. <small slot="more">...</small>
  24. </avue-text-ellipsis>
  25. </template>
  26. <template slot-scope="{ row }" slot="updateUser">
  27. <span>{{ row.updateUserName }}</span>
  28. </template>
  29. <template slot="menuLeft">
  30. <el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除
  31. </el-button>
  32. </template>
  33. <template slot-scope="{ row, index }" slot="menu">
  34. <el-button type="text" size="small" @click.stop="editOpen(row, 1)">
  35. 编辑
  36. </el-button>
  37. <!-- <el-button type="text" size="small" @click.stop="editOpen(row, 1)">
  38. 编辑
  39. </el-button> -->
  40. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  41. 删除
  42. </el-button>
  43. </template>
  44. </avue-crud>
  45. </basic-container>
  46. <detailPage v-if="!isShow" ref="detail" @goBack="goBack" @copyOrder="copyOrder" :detailData="detailData"></detailPage>
  47. </div>
  48. </template>
  49. <script>
  50. import detailPage from "./detailsPage";
  51. import { getRateList, deleteDetails } from "@/api/iosBasicData/rateManagement";
  52. export default {
  53. name: "index",
  54. components: {
  55. detailPage
  56. },
  57. data() {
  58. return {
  59. selectionList: [],
  60. form: {},
  61. dataList: [],
  62. loading: false,
  63. isShow: true,
  64. detailData: {},
  65. search: {},
  66. page: {
  67. pageSize: 10,
  68. currentPage: 1
  69. },
  70. option: {},
  71. optionBack: {
  72. searchShow: true,
  73. searchMenuSpan: 6,
  74. align: "center",
  75. border: true,
  76. index: true,
  77. viewBtn: false,
  78. editBtn: false,
  79. delBtn: false,
  80. menuWidth: 120,
  81. tip: false,
  82. selection: true,
  83. searchIcon: true,
  84. searchIndex: 3,
  85. calcHeight: 30,
  86. addBtnText: "新建币别及汇率",
  87. stripe: true,
  88. column: [
  89. {
  90. label: "编码",
  91. prop: "code",
  92. width: "180",
  93. overHidden: true,
  94. search: true
  95. },
  96. {
  97. label: "中文名称",
  98. prop: "cnName",
  99. width: "180",
  100. overHidden: true,
  101. search: true
  102. },
  103. {
  104. label: "英文名称",
  105. prop: "enName",
  106. width: "180",
  107. overHidden: true,
  108. search: true
  109. },
  110. {
  111. label: "国际三字码",
  112. prop: "unCode",
  113. overHidden: true,
  114. search: true
  115. },
  116. {
  117. label: "货币符号",
  118. prop: "symbol",
  119. overHidden: true
  120. },
  121. {
  122. label: "是否本币",
  123. prop: "isLocal",
  124. dicData: [{
  125. label: '非本币',
  126. value: 0
  127. }, {
  128. label: '本币',
  129. value: 1
  130. }],
  131. overHidden: true
  132. },
  133. {
  134. label: "对本币汇率",
  135. prop: "exrate",
  136. overHidden: true
  137. },
  138. {
  139. label: "国家编码",
  140. prop: "cntyCode",
  141. overHidden: true
  142. },
  143. {
  144. label: "国家名称",
  145. prop: "cntyName",
  146. overHidden: true
  147. },
  148. {
  149. label: "状态",
  150. prop: "status",
  151. type: "select",
  152. dicData: [{
  153. label: '启用',
  154. value: 0
  155. }, {
  156. label: '停用',
  157. value: 1
  158. }],
  159. value: 0,
  160. overHidden: true
  161. }
  162. ]
  163. }
  164. };
  165. },
  166. async created() {
  167. this.option.height = window.innerHeight - 210;
  168. this.option = await this.getColumnData(this.getColumnName(305), this.optionBack);
  169. },
  170. activated() {
  171. if (this.$route.query.check) {
  172. this.isShow = true;
  173. setTimeout(() => {
  174. this.editOpen({ id: this.$route.query.check.billId }, 1);
  175. }, 100);
  176. }
  177. },
  178. methods: {
  179. searchCriteriaSwitch(type) {
  180. if (type) {
  181. this.option.height = this.option.height - 46;
  182. } else {
  183. this.option.height = this.option.height + 46;
  184. }
  185. this.$refs.crud.getTableHeight();
  186. },
  187. cellStyle() {
  188. return "padding:0;height:40px;";
  189. },
  190. selectionChange(list) {
  191. this.selectionList = list;
  192. },
  193. //点击搜索按钮触发
  194. searchChange(params, done) {
  195. this.page.currentPage = 1;
  196. this.onLoad(this.page, params);
  197. done();
  198. },
  199. refreshChange() {
  200. this.onLoad(this.page, this.search);
  201. },
  202. currentChange(val) {
  203. this.page.currentPage = val;
  204. },
  205. sizeChange(val) {
  206. this.page.currentPage = 1;
  207. this.page.pageSize = val;
  208. },
  209. onLoad(page, params = {}) {
  210. this.loading = true;
  211. let queryParams = {
  212. ...params,
  213. ...this.search,
  214. size: page.pageSize,
  215. current: page.currentPage
  216. };
  217. getRateList(queryParams)
  218. .then(res => {
  219. this.dataList = res.data.data.records ? res.data.data.records : [];
  220. this.page.total = res.data.data.total;
  221. })
  222. .finally(() => {
  223. this.loading = false;
  224. });
  225. },
  226. //新增跳转页面
  227. beforeOpen() {
  228. this.isShow = false;
  229. },
  230. editOpen(row, status) {
  231. this.detailData = {
  232. id: row.id,
  233. status: status
  234. };
  235. this.isShow = false;
  236. },
  237. rowDel(row, index, done) {
  238. if (row.status === 1) {
  239. this.$confirm("确定删除数据?", {
  240. confirmButtonText: "确定",
  241. cancelButtonText: "取消",
  242. type: "warning"
  243. }).then(() => {
  244. deleteDetails(row.id).then(res => {
  245. if (res.data.code == 200) {
  246. this.$message({
  247. type: "success",
  248. message: "删除成功!"
  249. });
  250. this.onLoad(this.page, this.search);
  251. }
  252. });
  253. });
  254. } else {
  255. this.$message({
  256. message: '非禁用状态无法删除',
  257. type: 'warning'
  258. });
  259. }
  260. },
  261. goBack() {
  262. if (this.$route.query.check) {
  263. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  264. this.$router.push({
  265. path: "/salaryManagement/primarySchool/index"
  266. });
  267. }
  268. this.detailData = this.$options.data().detailData;
  269. this.onLoad(this.page, this.search);
  270. this.isShow = true;
  271. },
  272. handleDelete() {
  273. if (this.selectionList.length === 0) {
  274. this.$message.warning("请选择至少一条数据");
  275. return;
  276. }
  277. for (const selection of this.selectionList) {
  278. if (selection.status == 0) {
  279. this.$message.warning("选中的数据中有启用数据,启用数据不可删除!");
  280. return;
  281. }
  282. }
  283. this.$confirm("确定将选择数据删除?", {
  284. confirmButtonText: "确定",
  285. cancelButtonText: "取消",
  286. type: "warning"
  287. })
  288. .then(() => {
  289. return deleteDetails(this.ids);
  290. })
  291. .then(() => {
  292. this.onLoad(this.page);
  293. this.$message({
  294. type: "success",
  295. message: "操作成功!"
  296. });
  297. this.$refs.crud.toggleSelection();
  298. });
  299. },
  300. //自定义列保存
  301. async saveColumnTwo(ref, option, optionBack, code) {
  302. /**
  303. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  304. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  305. * 一定要执行异步操作,要等接口成功返回,才能执行下一行编码
  306. */
  307. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  308. if (inSave) {
  309. this.$message.success("保存成功");
  310. //关闭窗口
  311. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  312. }
  313. },
  314. //自定义列重置
  315. async resetColumnTwo(ref, option, optionBack, code) {
  316. this[option] = this[optionBack];
  317. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  318. if (inSave) {
  319. this.$message.success("重置成功");
  320. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  321. }
  322. },
  323. // 更改表格颜色
  324. headerClassName(tab) {
  325. //颜色间隔
  326. let back = ""
  327. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  328. if (tab.columnIndex % 2 === 0) {
  329. back = "back-one"
  330. } else if (tab.columnIndex % 2 === 1) {
  331. back = "back-two"
  332. }
  333. }
  334. return back;
  335. },
  336. }
  337. };
  338. </script>
  339. <style lang="scss" scoped>
  340. .page-crad ::v-deep .basic-container__card {
  341. height: 94.2vh;
  342. }
  343. ::v-deep#out-table .back-one {
  344. background: #ecf5ff !important;
  345. }
  346. ::v-deep#out-table .back-two {
  347. background: #ecf5ff !important;
  348. }
  349. /deep/ .el-col-md-8 {
  350. width: 24.33333%;
  351. }
  352. </style>