index.vue 8.7 KB

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