index.vue 11 KB

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