You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

312 lines
9.0 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div>
  3. <div style="position: relative">
  4. <div class="middlebox">
  5. <div class="contenttitle">
  6. 基础资料 /
  7. <span class="contenttitleBold"
  8. >支付方式</span
  9. >
  10. </div>
  11. </div>
  12. <div style="display: block; margin-top: 7px; margin-right: 110px">
  13. <div style="background-color: #fff; padding: 15px; border-radius: 8px">
  14. <el-table
  15. :data="tableData"
  16. row-key="id"
  17. :height="window.pageHeight < 600 ? 480 : window.pageHeight - 130"
  18. class="el-table__body-wrapper tbody"
  19. @row-click="rowick"
  20. highlight-current-row
  21. ref="tableData"
  22. >
  23. <el-table-column prop="id" label="编号" min-width="80" align="center"/>
  24. <el-table-column prop="displayName" label="名称" min-width="80" align="center"/>
  25. <el-table-column prop="simpleCode" label="快捷码" min-width="80" align="center"/>
  26. <el-table-column prop="isActive" label="启用" min-width="80" align="center">
  27. <template slot-scope="scope">
  28. <div>{{ scope.row.isActive == 'Y' ? '是':'否'}}</div>
  29. </template>
  30. </el-table-column>
  31. <el-table-column label="操作" align="center">
  32. <template>
  33. <el-tag
  34. class="move"
  35. style="
  36. cursor: move;
  37. background-color: rgb(245, 245, 245);
  38. border: none;
  39. "
  40. draggable="true"
  41. >
  42. <i
  43. class="el-icon-d-caret"
  44. style="width: 1rem; height: 1rem; color: rgb(113, 113, 113)"
  45. ></i>
  46. </el-tag>
  47. </template>
  48. </el-table-column>
  49. </el-table>
  50. </div>
  51. </div>
  52. <!-- 按钮 -->
  53. <div style="margin-left: 10px;margin-top: 3%;position: absolute;top: 0;right: 0;">
  54. <div>
  55. <el-button type="" @click="editpopup" class="commonbutton">编辑</el-button>
  56. </div>
  57. <div style="margin-top: 10px">
  58. <el-button type="" @click="topping" class="commonbutton"
  59. >置顶</el-button
  60. >
  61. </div>
  62. <div style="margin-top: 10px">
  63. <el-button type="" @click="toppings" class="commonbutton"
  64. >置底</el-button
  65. >
  66. </div>
  67. <div style="margin-top: 10px">
  68. <el-button
  69. type=""
  70. :disabled="isshow"
  71. @click="assertion"
  72. class="commonbutton"
  73. >排序</el-button
  74. >
  75. </div>
  76. <div style="margin-top: 10px">
  77. <el-button
  78. type=""
  79. :disabled="isshow"
  80. @click="cancellation"
  81. class="commonbutton"
  82. >取消</el-button
  83. >
  84. </div>
  85. </div>
  86. </div>
  87. <!-- 新增或者编辑 -->
  88. <el-dialog
  89. title="修改"
  90. :visible.sync="dialogVisible"
  91. width="600px"
  92. :close-on-click-modal="false"
  93. >
  94. <el-form ref="form" :model="form" label-width="80px">
  95. <el-row>
  96. <el-col :span="12">
  97. <el-form-item label="编号">
  98. <el-input v-model="form.id" disabled size="small"></el-input>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="12">
  102. <el-form-item label="名称">
  103. <el-input v-model="form.displayName" size="small"></el-input>
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <el-row>
  108. <el-col :span="12">
  109. <el-form-item label="启用">
  110. <el-radio v-model="form.isActive" label="Y"></el-radio>
  111. <el-radio v-model="form.isActive" label="N"></el-radio>
  112. </el-form-item>
  113. </el-col>
  114. </el-row>
  115. </el-form>
  116. <span slot="footer" class="dialog-footer">
  117. <el-button @click="dialogVisible = false" class="difference"> </el-button>
  118. <el-button type="primary" @click="addoredit" class="commonbutton"
  119. > </el-button
  120. >
  121. </span>
  122. </el-dialog>
  123. </div>
  124. </template>
  125. <script>
  126. import Sortable from "sortablejs";
  127. import {
  128. paymodelist,
  129. paymentediting,
  130. paytopandbottom,
  131. paymentdraganddrop,
  132. } from "@/request/commonapi";
  133. import { mapState } from "vuex"
  134. export default {
  135. data() {
  136. return {
  137. isshow: true,
  138. initTableData: [],
  139. tableData: [],
  140. form: {
  141. displayName: "",
  142. isActive: "Y",
  143. },
  144. dialogVisible: false,
  145. };
  146. },
  147. created() {
  148. this.getlist();
  149. },
  150. mounted() {
  151. this.rowDrop();
  152. },
  153. watch: {
  154. },
  155. computed:{
  156. ...mapState(['window'])
  157. },
  158. methods: {
  159. //取消排序
  160. cancellation() {
  161. this.$message.info("取消操作");
  162. this.isshow = true;
  163. this.getlist();
  164. },
  165. //确定拖拽
  166. assertion() {
  167. const result = [];
  168. this.tableData.forEach((item, index) => {
  169. // index 从0开始的, displayOrder从大到小排
  170. // const currentDisplayOrder = this.tableData.length -1
  171. // const currentDisplayOrder = this.initTableData[index].displayOrder;
  172. // if (item.displayOrder != currentDisplayOrder) {
  173. // 如果它的displayOrder和它当前所在的位置不同代表挪动过位置
  174. result.push({
  175. id: item.id,
  176. displayOrder: index+1,
  177. });
  178. // }
  179. });
  180. paymentdraganddrop({ itemList: result }).then((res) => {
  181. if(res.code!=-1){
  182. this.isshow = true;
  183. this.getlist();
  184. //this.$message.success('操作成功')
  185. }
  186. });
  187. },
  188. //初始化
  189. rowDrop() {
  190. this.$nextTick(() => {
  191. const tbody = document.querySelector(".el-table__body-wrapper tbody");
  192. const _this = this;
  193. Sortable.create(tbody, {
  194. handle: ".move",
  195. animation: 300,
  196. onChoose({ oldIndex }) {
  197. _this.$refs["tableData"].setCurrentRow(_this.tableData[oldIndex]);
  198. _this.rowick(_this.tableData[oldIndex]);
  199. },
  200. onEnd({ newIndex, oldIndex }) {
  201. _this.isshow = false;
  202. const currRow = _this.tableData.splice(oldIndex, 1)[0];
  203. _this.tableData.splice(newIndex, 0, currRow);
  204. _this.tableData.map((item, index) => {
  205. if (index == newIndex && index == oldIndex) {
  206. // console.log(item, "新数据");
  207. } else if (index == oldIndex) {
  208. } else if (index == newIndex) {
  209. }
  210. });
  211. },
  212. });
  213. });
  214. },
  215. //置低
  216. toppings() {
  217. if (this.form.id == undefined) {
  218. this.$message.warning("请点击选择操作的数据");
  219. } else {
  220. paytopandbottom(this.form.id, 2).then((res) => {
  221. if(res.code!=-1){
  222. this.getlist();
  223. //this.$message.success('操作成功')
  224. }
  225. });
  226. }
  227. },
  228. //置顶
  229. topping() {
  230. if (this.form.id == undefined) {
  231. this.$message.warning("请点击选择操作的数据");
  232. } else {
  233. paytopandbottom(this.form.id, 1).then((res) => {
  234. if(res.code!=-1){
  235. this.getlist();
  236. //this.$message.success('操作成功')
  237. }
  238. });
  239. }
  240. },
  241. // 确定修改编辑
  242. addoredit() {
  243. if (this.form.displayName == "" || this.form.displayName == undefined) {
  244. this.$message.warning("请输入名称");
  245. } else {
  246. paymentediting(this.form.id, {
  247. displayName: this.form.displayName,
  248. isActive:this.form.isActive
  249. }).then((res) => {
  250. if(res.code!=-1){
  251. this.getlist();
  252. this.dialogVisible = false;
  253. //this.$message.success('修改成功')
  254. }
  255. });
  256. }
  257. },
  258. //编辑弹框
  259. editpopup() {
  260. if (this.form.id == undefined) {
  261. this.$message.warning("请点击选择操作的数据");
  262. } else {
  263. this.dialogVisible = true;
  264. }
  265. },
  266. rowick(row) {
  267. this.form = Object.assign({},row);
  268. },
  269. getlist() {
  270. paymodelist().then((res) => {
  271. if(res.code!=-1){
  272. this.initTableData = [...res.data];
  273. this.tableData = res.data;
  274. }
  275. });
  276. },
  277. },
  278. };
  279. </script>
  280. <style scoped>
  281. @import "../../assets/css/global_button.css";
  282. @import "../../assets/css/global_dialog.css";
  283. @import "../../assets/css/global_table.css";
  284. @import "../../assets/css/global_form.css";
  285. @import "../../assets/css/global_input.css";
  286. @import "../../assets/css/global.css";
  287. .box {
  288. display: flex;
  289. flex-direction: column;
  290. }
  291. :deep .el-form-item {
  292. margin-bottom: 14px;
  293. }
  294. /* el-dialog的头部样式 */
  295. :deep .el-dialog__header {
  296. padding: 11px 20px 11px;
  297. }
  298. /* el-dialog的主体样式 */
  299. :deep .el-dialog__body {
  300. padding: 0px 20px 0px;
  301. }
  302. /* el-divider样式 */
  303. :deep .el-divider--horizontal {
  304. margin: 0px 0 12px;
  305. }
  306. /* el-dialog的底部样式 */
  307. :deep .el-dialog__footer {
  308. padding: 0px 20px 14px;
  309. }
  310. </style>