index.vue 9.1 KB

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