index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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. <span v-hasPermi="['otaMr:otaMr:edit']" style="display: inline-block;">
  54. <el-button
  55. size="mini"
  56. type="text"
  57. style="margin-left: 10px;"
  58. v-if="scope.row.status != '1'"
  59. @click="handleUpdate(scope.row,scope.index)"
  60. >修改</el-button>
  61. </span>
  62. <span v-hasPermi="['otaMr:otaMr:delete']" style="display: inline-block;">
  63. <el-button
  64. size="mini"
  65. type="text"
  66. style="margin-left: 10px;"
  67. v-if="scope.row.status != '1'"
  68. @click="handleDelete(scope.row,scope.index)"
  69. >删除</el-button>
  70. </span>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. <pagination
  75. v-show="total>0"
  76. :total="total"
  77. :page.sync="queryParams.pageNum"
  78. :limit.sync="queryParams.pageSize"
  79. @pagination="getList"
  80. />
  81. <!-- 新增/编辑弹框 -->
  82. <add-and-edit
  83. ref="addAndEdit"
  84. :dict="dict"
  85. @getList="getList"
  86. />
  87. <!-- 编辑商品弹框 -->
  88. <data-edit
  89. ref="dataEdit"
  90. @getList="getList"
  91. :dict="dict"></data-edit>
  92. <el-dialog
  93. title="填写密钥"
  94. :visible.sync="visibleStatus"
  95. width="600px"
  96. :destroy-on-close="true"
  97. :close-on-click-modal="false"
  98. >
  99. <div class="dialog">
  100. <el-form :model="otaForm" ref="otaForm" :rules="otaRules" label-width="120px">
  101. <el-form-item label="供应商id" prop="name">
  102. <el-input
  103. v-model="otaForm.name"
  104. placeholder=""
  105. clearable
  106. style="width: 100%;"
  107. />
  108. </el-form-item>
  109. <el-form-item label="client id" prop="otaKey">
  110. <el-input
  111. v-model="otaForm.otaKey"
  112. placeholder=""
  113. clearable
  114. style="width: 100%;"
  115. />
  116. </el-form-item>
  117. <el-form-item label="client secret" prop="otaValue">
  118. <el-input
  119. v-model="otaForm.otaValue"
  120. placeholder=""
  121. clearable
  122. style="width: 100%;"
  123. />
  124. </el-form-item>
  125. </el-form>
  126. </div>
  127. <div slot="footer" class="dialog-footer">
  128. <el-button @click="visibleStatus = false">取消</el-button>
  129. <el-button
  130. type="primary"
  131. @click="submitForm"
  132. v-loading.fullscreen.lock="otaLoading"
  133. element-loading-text="提交中..."
  134. element-loading-spinner="el-icon-loading"
  135. element-loading-background="rgba(0, 0, 0, 0.8)"
  136. >
  137. <span v-if="otaLoading">提交中...</span>
  138. <span v-else>保存</span>
  139. </el-button>
  140. </div>
  141. </el-dialog>
  142. </div>
  143. </template>
  144. <script>
  145. import { pageList, deleteById, getOtaConfig, otaSave } from '@/api/otaMr/otaMr'
  146. import addAndEdit from "./dialog/addAndEdit.vue";
  147. import dataEdit from "./dialog/dataEdit.vue";
  148. export default {
  149. name: "ThirdParty",
  150. dicts: ['agreement_type'],
  151. components: { addAndEdit, dataEdit },
  152. data() {
  153. return {
  154. // 遮罩层
  155. loading: true,
  156. otaLoading: false,
  157. // 选中数组
  158. ids: [],
  159. // 非单个禁用
  160. single: true,
  161. // 非多个禁用
  162. multiple: true,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. total: 0,
  167. // 用户表格数据
  168. dataList: null,
  169. // 弹出层标题
  170. title: "",
  171. otaType: '1',
  172. // 是否显示弹出层
  173. open: false,
  174. // 日期范围
  175. dateRange: [],
  176. // 查询参数
  177. queryParams: {
  178. pageNum: 1,
  179. pageSize: 10,
  180. ota: '1'
  181. },
  182. visibleStatus: false,
  183. newObj: {},
  184. visibleType: '',
  185. otaForm: {},
  186. otaRules: {
  187. name: [{ required: true, message: "请输入供应商id", trigger: ["change","blur"] }],
  188. otaKey: [{ required: true, message: "请输入client id", trigger: ["change","blur"] }],
  189. otaValue: [{ required: true, message: "请输入client secret", trigger: ["change","blur"] }]
  190. },
  191. };
  192. },
  193. created() {
  194. this.getList();
  195. },
  196. methods: {
  197. /** 查询列表 */
  198. getList() {
  199. this.loading = true;
  200. this.queryParams.ota = this.otaType
  201. pageList(this.addDateRange(this.queryParams, this.dateRange))
  202. .then(response => {
  203. this.dataList = response.data.rows;
  204. this.total = response.data.total;
  205. this.loading = false;
  206. }
  207. );
  208. },
  209. // 取消按钮
  210. cancel() {
  211. this.open = false;
  212. },
  213. /** 搜索按钮操作 */
  214. handleQuery() {
  215. this.queryParams.pageNum = 1;
  216. this.getList();
  217. },
  218. /** 重置按钮操作 */
  219. resetQuery() {
  220. this.dateRange = [];
  221. this.dataList = [];
  222. this.queryParams.pageNum = 1;
  223. this.handleQuery();
  224. },
  225. /** 新增按钮操作 */
  226. handleAdd() {
  227. this.$refs["addAndEdit"].openDialog("新增数据", this.queryParams);
  228. },
  229. /** 修改按钮操作 */
  230. handleUpdate(row) {
  231. this.$refs["dataEdit"].openDialog("修改数据", row);
  232. },
  233. /** 删除按钮操作 */
  234. handleDelete(row) {
  235. this.$modal.confirm('是否确认删除商品名称为"' + row.goodsName + '"的数据项?').then(function() {
  236. return deleteById(row.id);
  237. }).then(() => {
  238. this.getList();
  239. this.$modal.msgSuccess("删除成功");
  240. }).catch(() => {});
  241. },
  242. /** 查看按钮操作 */
  243. handleKey(obj, type) {
  244. this.visibleStatus = true
  245. this.visibleType = type;
  246. this.otaForm = {};
  247. this.getOtaConfigApi();
  248. },
  249. /** 查询列表 */
  250. getOtaConfigApi() {
  251. getOtaConfig({ota: this.otaType})
  252. .then(response => {
  253. let dataList = response.data;
  254. dataList.forEach(item => {
  255. this.$set(this.otaForm, item.otaKey, item.otaValue);
  256. })
  257. });
  258. },
  259. /**
  260. * 保存
  261. * @date 2023-11-22
  262. * @returns {any}
  263. */
  264. submitForm() {
  265. this.$refs["otaForm"].validate(async (valid) => {
  266. if (valid) {
  267. try {
  268. let postList = [];
  269. for (const key in this.otaForm) {
  270. postList.push({
  271. ota: this.otaType,
  272. otaKey: key,
  273. otaValue: this.otaForm[key]
  274. })
  275. }
  276. this.otaLoading = true;
  277. const { code } = await otaSave(postList);
  278. if (code === 200) {
  279. this.$message.success("操作成功!");
  280. this.getList();
  281. this.visibleStatus = false;
  282. }
  283. } catch (error) {
  284. } finally {
  285. this.otaLoading = false;
  286. }
  287. }
  288. });
  289. },
  290. }
  291. };
  292. </script>