index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="app-container">
  3. <div class="top-taber" style="margin-top: 10px">
  4. <el-radio-group v-model="otaType" size="small" @change="handleQuery">
  5. <el-radio-button label="1">美团</el-radio-button>
  6. <el-radio-button label="2">携程</el-radio-button>
  7. </el-radio-group>
  8. </div>
  9. <el-row :gutter="10" class="mb8" style="margin-top: 30px">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. plain
  14. icon="el-icon-key"
  15. size="mini"
  16. @click="handleKey"
  17. v-hasPermi="['otaMr:otaMr:key']"
  18. >填写密钥</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button
  22. type="primary"
  23. plain
  24. icon="el-icon-plus"
  25. size="mini"
  26. @click="handleAdd"
  27. v-hasPermi="['otaMr:otaMr:add']"
  28. >添加商品</el-button>
  29. </el-col>
  30. <right-toolbar :showSearch.sync="showSearch" :search="false" @queryTable="getList"></right-toolbar>
  31. </el-row>
  32. <el-table ref="tables" v-loading="loading" :data="dataList" border>
  33. <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
  34. <el-table-column label="商品名称" align="center" prop="goodsName" />
  35. <!-- <el-table-column label="类型" align="center" prop="goodsName" />-->
  36. <!-- <el-table-column label="市场价" align="center" prop="otaPrice">-->
  37. <!-- <template slot-scope="scope">-->
  38. <!-- <span>¥{{ scope.row.otaPrice }}</span>-->
  39. <!-- </template>-->
  40. <!-- </el-table-column>-->
  41. <el-table-column label="销售价格" align="center" prop="otaPrice">
  42. <template slot-scope="scope">
  43. <span>¥{{ scope.row.otaPrice }}</span>
  44. </template>
  45. </el-table-column>
  46. <!-- <el-table-column label="结算价" align="center" prop="otaPrice">-->
  47. <!-- <template slot-scope="scope">-->
  48. <!-- <span>¥{{ scope.row.otaPrice }}</span>-->
  49. <!-- </template>-->
  50. <!-- </el-table-column>-->
  51. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  52. <template slot-scope="scope">
  53. <el-button
  54. size="mini"
  55. type="text"
  56. v-if="scope.row.status != '1'"
  57. @click="handleDelete(scope.row,scope.index)"
  58. v-hasPermi="['otaMr:otaMr:delete']"
  59. >删除</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <pagination
  64. v-show="total>0"
  65. :total="total"
  66. :page.sync="queryParams.pageNum"
  67. :limit.sync="queryParams.pageSize"
  68. @pagination="getList"
  69. />
  70. <!-- 新增/编辑弹框 -->
  71. <add-and-edit
  72. ref="addAndEdit"
  73. :dict="dict"
  74. @getList="getList"
  75. />
  76. <el-dialog
  77. title="填写密钥"
  78. :visible.sync="visibleStatus"
  79. width="600px"
  80. :destroy-on-close="true"
  81. :close-on-click-modal="false"
  82. >
  83. <div class="dialog">
  84. <el-form :model="otaForm" ref="otaForm" :rules="otaRules" label-width="120px">
  85. <el-form-item label="供应商id" prop="name">
  86. <el-input
  87. v-model="otaForm.name"
  88. placeholder=""
  89. clearable
  90. style="width: 100%;"
  91. />
  92. </el-form-item>
  93. <el-form-item label="client id" prop="otaKey">
  94. <el-input
  95. v-model="otaForm.otaKey"
  96. placeholder=""
  97. clearable
  98. style="width: 100%;"
  99. />
  100. </el-form-item>
  101. <el-form-item label="client secret" prop="otaValue">
  102. <el-input
  103. v-model="otaForm.otaValue"
  104. placeholder=""
  105. clearable
  106. style="width: 100%;"
  107. />
  108. </el-form-item>
  109. </el-form>
  110. </div>
  111. <div slot="footer" class="dialog-footer">
  112. <el-button @click="visibleStatus = false">取消</el-button>
  113. <el-button
  114. type="primary"
  115. @click="submitForm"
  116. v-loading.fullscreen.lock="otaLoading"
  117. element-loading-text="提交中..."
  118. element-loading-spinner="el-icon-loading"
  119. element-loading-background="rgba(0, 0, 0, 0.8)"
  120. >
  121. <span v-if="otaLoading">提交中...</span>
  122. <span v-else>保存</span>
  123. </el-button>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import { pageList, deleteById, getOtaConfig, otaSave } from '@/api/otaMr/otaMr'
  130. import addAndEdit from "./dialog/addAndEdit.vue";
  131. export default {
  132. name: "agreement",
  133. dicts: ['agreement_type'],
  134. components: { addAndEdit },
  135. data() {
  136. return {
  137. // 遮罩层
  138. loading: true,
  139. otaLoading: false,
  140. // 选中数组
  141. ids: [],
  142. // 非单个禁用
  143. single: true,
  144. // 非多个禁用
  145. multiple: true,
  146. // 显示搜索条件
  147. showSearch: true,
  148. // 总条数
  149. total: 0,
  150. // 用户表格数据
  151. dataList: null,
  152. // 弹出层标题
  153. title: "",
  154. otaType: '1',
  155. // 是否显示弹出层
  156. open: false,
  157. // 日期范围
  158. dateRange: [],
  159. // 查询参数
  160. queryParams: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. ota: '1'
  164. },
  165. visibleStatus: false,
  166. newObj: {},
  167. visibleType: '',
  168. otaForm: {},
  169. otaRules: {
  170. name: [{ required: true, message: "请输入供应商id", trigger: "blur" }],
  171. otaKey: [{ required: true, message: "请输入client id", trigger: "blur" }],
  172. otaValue: [{ required: true, message: "请输入client secret", trigger: "blur" }]
  173. },
  174. };
  175. },
  176. created() {
  177. this.getList();
  178. },
  179. methods: {
  180. /** 查询列表 */
  181. getList() {
  182. this.loading = true;
  183. this.queryParams.ota = this.otaType
  184. pageList(this.addDateRange(this.queryParams, this.dateRange))
  185. .then(response => {
  186. this.dataList = response.data.rows;
  187. this.total = response.data.total;
  188. this.loading = false;
  189. }
  190. );
  191. },
  192. // 取消按钮
  193. cancel() {
  194. this.open = false;
  195. },
  196. /** 搜索按钮操作 */
  197. handleQuery() {
  198. this.queryParams.pageNum = 1;
  199. this.getList();
  200. },
  201. /** 重置按钮操作 */
  202. resetQuery() {
  203. this.dateRange = [];
  204. this.dataList = [];
  205. this.queryParams.pageNum = 1;
  206. this.handleQuery();
  207. },
  208. /** 新增按钮操作 */
  209. handleAdd() {
  210. this.$refs["addAndEdit"].openDialog("新增数据", this.queryParams);
  211. },
  212. /** 删除按钮操作 */
  213. handleDelete(row) {
  214. this.$modal.confirm('是否确认删除商品名称为"' + row.goodsName + '"的数据项?').then(function() {
  215. return deleteById(row.id);
  216. }).then(() => {
  217. this.getList();
  218. this.$modal.msgSuccess("删除成功");
  219. }).catch(() => {});
  220. },
  221. /** 查看按钮操作 */
  222. handleKey(obj, type) {
  223. this.visibleStatus = true
  224. this.visibleType = type;
  225. this.otaForm = {};
  226. this.getOtaConfigApi();
  227. },
  228. /** 查询列表 */
  229. getOtaConfigApi() {
  230. getOtaConfig({ota: this.otaType})
  231. .then(response => {
  232. let dataList = response.data;
  233. dataList.forEach(item => {
  234. this.$set(this.otaForm, item.otaKey, item.otaValue);
  235. })
  236. });
  237. },
  238. /**
  239. * 保存
  240. * @date 2023-11-22
  241. * @returns {any}
  242. */
  243. submitForm() {
  244. this.$refs["otaForm"].validate(async (valid) => {
  245. if (valid) {
  246. try {
  247. let postList = [];
  248. for (const key in this.otaForm) {
  249. postList.push({
  250. ota: this.otaType,
  251. otaKey: key,
  252. otaValue: this.otaForm[key]
  253. })
  254. }
  255. this.otaLoading = true;
  256. const { code } = await otaSave(postList);
  257. if (code === 200) {
  258. this.$message.success("操作成功!");
  259. this.getList();
  260. this.visibleStatus = false;
  261. }
  262. } catch (error) {
  263. } finally {
  264. this.otaLoading = false;
  265. }
  266. }
  267. });
  268. },
  269. }
  270. };
  271. </script>