addAndEdit.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: Sugar.
  6. * @LastEditTime: 2023-11-24 13:55:00
  7. * @FilePath: \cattle_webui\src\views\otaMr\dialog\AddOrEditDialog.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog
  12. :title="title"
  13. :visible.sync="open"
  14. width="700px"
  15. append-to-body
  16. :close-on-click-modal="false"
  17. @close="cancel"
  18. >
  19. <div class="dialog" style="padding: 0">
  20. <el-table ref="tables" v-loading="tabLoading" :data="dataList" border @selection-change="handleSelectionChange">
  21. <el-table-column type="selection" width="50" align="center" />
  22. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  23. <el-table-column label="票务名称" align="center" prop="goodsName" />
  24. <el-table-column label="座位类型" align="center" prop="goodsName" />
  25. <el-table-column label="市场价" align="center" prop="salePrice" width="160">
  26. <template slot-scope="scope">
  27. <span>¥{{ scope.row.salePrice }}</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="销售价" align="center" prop="salePrice" width="160">
  31. <template slot-scope="scope">
  32. <span>¥{{ scope.row.salePrice }}</span>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="结算价" align="center" prop="salePrice" width="160">
  36. <template slot-scope="scope">
  37. <el-input
  38. type="number"
  39. v-model="scope.row.salePrice"
  40. placeholder=""
  41. clearable
  42. @change="changePriceAmount('salePrice')"
  43. style="width: 260px;"
  44. >
  45. </el-input>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. <pagination
  50. v-show="total>0"
  51. :total="total"
  52. :page.sync="queryParams.pageNum"
  53. :limit.sync="queryParams.pageSize"
  54. @pagination="getList"
  55. />
  56. </div>
  57. <span slot="footer" class="dialog-footer">
  58. <el-button @click="cancel">取消</el-button>
  59. <el-button
  60. type="primary"
  61. @click="submitForm"
  62. v-loading.fullscreen.lock="loading"
  63. element-loading-text="提交中..."
  64. element-loading-spinner="el-icon-loading"
  65. element-loading-background="rgba(0, 0, 0, 0.8)"
  66. >
  67. <span v-if="loading">提交中...</span>
  68. <span v-else>确认添加</span>
  69. </el-button>
  70. </span>
  71. </el-dialog>
  72. </template>
  73. <script>
  74. import { goodsList, saveAndEdit } from '@/api/otaMr/otaMr'
  75. import Editor from "@/components/Editor";
  76. import { getToken } from "@/utils/auth";
  77. export default {
  78. name: "addAndEdit",
  79. props: {
  80. dict: {
  81. type: Object,
  82. default: () => [],
  83. },
  84. },
  85. components: {
  86. Editor,
  87. },
  88. data() {
  89. return {
  90. title: "编辑",
  91. model: "EDIT",
  92. open: false,
  93. loading: false,
  94. tabLoading: false,
  95. dataList: [],
  96. total: 0,
  97. // 查询参数
  98. queryParams: {
  99. pageNum: 1,
  100. pageSize: 10,
  101. ota: '1'
  102. },
  103. selectList: []
  104. };
  105. },
  106. methods: {
  107. /**
  108. * 打开弹框
  109. * @date 2023-11-22
  110. * @param {any} obj
  111. * @returns {any}
  112. */
  113. openDialog(title, obj) {
  114. this.open = true;
  115. this.title = "票务信息";
  116. this.getList(obj);
  117. },
  118. /** 价格输入事件 */
  119. changePriceAmount(row) {
  120. if(row.salePrice * 1 < 0){
  121. this.$message.error("输入需大于或等于0!");
  122. row.salePrice = '';
  123. return false
  124. }
  125. },
  126. /** 查询列表 */
  127. getList(obj) {
  128. this.tabLoading = true;
  129. this.queryParams.ota = obj.ota;
  130. goodsList(this.queryParams)
  131. .then(response => {
  132. // this.dataList = response.data.rows;
  133. // this.total = response.data.total;
  134. // this.tabLoading = false;
  135. this.dataList = response.data;
  136. this.tabLoading = false;
  137. }
  138. ).catch(() => {
  139. this.tabLoading = false;
  140. });
  141. },
  142. // 多选框选中数据
  143. handleSelectionChange(selection) {
  144. this.selectList = selection;
  145. },
  146. /**
  147. * 保存
  148. * @date 2023-11-22
  149. * @returns {any}
  150. */
  151. async submitForm() {
  152. try {
  153. if(this.selectList.length <= 0) {
  154. this.$message.error("请勾选商品!");
  155. return false
  156. }
  157. let postList = [];
  158. this.selectList.forEach(item => {
  159. postList.push({
  160. "ota": this.queryParams.ota,
  161. "goodsId": item.id,
  162. "otaPrice": item.salePrice
  163. })
  164. })
  165. this.loading = true;
  166. const { code } = await saveAndEdit(postList);
  167. if (code === 200) {
  168. this.$message.success("操作成功!");
  169. this.$emit("getList");
  170. this.cancel();
  171. }
  172. } catch (error) {
  173. } finally {
  174. this.loading = false;
  175. }
  176. },
  177. /**
  178. * 重置
  179. * @date 2023-11-22
  180. * @returns {any}
  181. */
  182. reset() {
  183. },
  184. /**
  185. * 关闭弹框
  186. * @date 2023-11-22
  187. * @returns {any}
  188. */
  189. cancel() {
  190. this.open = false;
  191. }
  192. },
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .dialog {
  197. padding: 0 30px;
  198. max-height: 65vh;
  199. overflow-y: auto;
  200. }
  201. .dialog {
  202. padding: 0 30px;
  203. .upload-btn {
  204. width: 100px;
  205. height: 100px;
  206. background-color: #fbfdff;
  207. border: dashed 1px #c0ccda;
  208. border-radius: 5px;
  209. i {
  210. font-size: 30px;
  211. margin-top: 20px;
  212. }
  213. &-text {
  214. margin-top: -10px;
  215. }
  216. }
  217. .avatar {
  218. cursor: pointer;
  219. }
  220. }
  221. </style>