123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <template>
- <div class="app-container">
- <div class="top-taber" style="margin-top: 10px">
- <el-radio-group v-model="otaType" size="small" @change="handleQuery">
- <el-radio-button label="1">美团</el-radio-button>
- <el-radio-button label="2">携程</el-radio-button>
- </el-radio-group>
- </div>
- <el-row :gutter="10" class="mb8" style="margin-top: 30px">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-key"
- size="mini"
- @click="handleKey"
- v-hasPermi="['otaMr:otaMr:key']"
- >填写密钥</el-button>
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['otaMr:otaMr:add']"
- >添加商品</el-button>
- </el-col>
- <right-toolbar :showSearch.sync="showSearch" :search="false" @queryTable="getList"></right-toolbar>
- </el-row>
- <el-table ref="tables" v-loading="loading" :data="dataList" border>
- <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
- <el-table-column label="商品名称" align="center" prop="goodsName" />
- <el-table-column label="类型" align="center" prop="goodsName" />
- <el-table-column label="市场价" align="center" prop="otaPrice">
- <template slot-scope="scope">
- <span>¥{{ scope.row.otaPrice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="销售价格" align="center" prop="otaPrice">
- <template slot-scope="scope">
- <span>¥{{ scope.row.otaPrice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="结算价" align="center" prop="otaPrice">
- <template slot-scope="scope">
- <span>¥{{ scope.row.otaPrice }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
- <template slot-scope="scope">
- <span v-hasPermi="['otaMr:otaMr:edit']" style="display: inline-block;margin-left: 10px;">
- <el-button
- size="mini"
- type="text"
- v-if="scope.row.status != '1'"
- @click="handleUpdate(scope.row,scope.index)"
- >修改</el-button>
- </span>
- <span v-hasPermi="['otaMr:otaMr:delete']" style="display: inline-block;margin-left: 10px;">
- <el-button
- size="mini"
- type="text"
- v-if="scope.row.status != '1'"
- @click="handleDelete(scope.row,scope.index)"
- >删除</el-button>
- </span>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 新增/编辑弹框 -->
- <add-and-edit
- ref="addAndEdit"
- :dict="dict"
- @getList="getList"
- />
- <!-- 编辑商品弹框 -->
- <data-edit
- ref="dataEdit"
- @getList="getList"
- :dict="dict"></data-edit>
- <el-dialog
- title="填写密钥"
- :visible.sync="visibleStatus"
- width="600px"
- :destroy-on-close="true"
- :close-on-click-modal="false"
- >
- <div class="dialog">
- <el-form :model="otaForm" ref="otaForm" :rules="otaRules" label-width="120px">
- <el-form-item label="供应商id" prop="name">
- <el-input
- v-model="otaForm.name"
- placeholder=""
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- <el-form-item label="client id" prop="otaKey">
- <el-input
- v-model="otaForm.otaKey"
- placeholder=""
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- <el-form-item label="client secret" prop="otaValue">
- <el-input
- v-model="otaForm.otaValue"
- placeholder=""
- clearable
- style="width: 100%;"
- />
- </el-form-item>
- </el-form>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button @click="visibleStatus = false">取消</el-button>
- <el-button
- type="primary"
- @click="submitForm"
- v-loading.fullscreen.lock="otaLoading"
- element-loading-text="提交中..."
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- >
- <span v-if="otaLoading">提交中...</span>
- <span v-else>保存</span>
- </el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { pageList, deleteById, getOtaConfig, otaSave } from '@/api/otaMr/otaMr'
- import addAndEdit from "./dialog/addAndEdit.vue";
- import dataEdit from "./dialog/dataEdit.vue";
- export default {
- name: "agreement",
- dicts: ['agreement_type'],
- components: { addAndEdit, dataEdit },
- data() {
- return {
- // 遮罩层
- loading: true,
- otaLoading: false,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 用户表格数据
- dataList: null,
- // 弹出层标题
- title: "",
- otaType: '1',
- // 是否显示弹出层
- open: false,
- // 日期范围
- dateRange: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- ota: '1'
- },
- visibleStatus: false,
- newObj: {},
- visibleType: '',
- otaForm: {},
- otaRules: {
- name: [{ required: true, message: "请输入供应商id", trigger: ["change","blur"] }],
- otaKey: [{ required: true, message: "请输入client id", trigger: ["change","blur"] }],
- otaValue: [{ required: true, message: "请输入client secret", trigger: ["change","blur"] }]
- },
- };
- },
- created() {
- this.getList();
- },
- methods: {
- /** 查询列表 */
- getList() {
- this.loading = true;
- this.queryParams.ota = this.otaType
- pageList(this.addDateRange(this.queryParams, this.dateRange))
- .then(response => {
- this.dataList = response.data.rows;
- this.total = response.data.total;
- this.loading = false;
- }
- );
- },
- // 取消按钮
- cancel() {
- this.open = false;
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.dateRange = [];
- this.dataList = [];
- this.queryParams.pageNum = 1;
- this.handleQuery();
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.$refs["addAndEdit"].openDialog("新增数据", this.queryParams);
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.$refs["dataEdit"].openDialog("修改数据", row);
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- this.$modal.confirm('是否确认删除商品名称为"' + row.goodsName + '"的数据项?').then(function() {
- return deleteById(row.id);
- }).then(() => {
- this.getList();
- this.$modal.msgSuccess("删除成功");
- }).catch(() => {});
- },
- /** 查看按钮操作 */
- handleKey(obj, type) {
- this.visibleStatus = true
- this.visibleType = type;
- this.otaForm = {};
- this.getOtaConfigApi();
- },
- /** 查询列表 */
- getOtaConfigApi() {
- getOtaConfig({ota: this.otaType})
- .then(response => {
- let dataList = response.data;
- dataList.forEach(item => {
- this.$set(this.otaForm, item.otaKey, item.otaValue);
- })
- });
- },
- /**
- * 保存
- * @date 2023-11-22
- * @returns {any}
- */
- submitForm() {
- this.$refs["otaForm"].validate(async (valid) => {
- if (valid) {
- try {
- let postList = [];
- for (const key in this.otaForm) {
- postList.push({
- ota: this.otaType,
- otaKey: key,
- otaValue: this.otaForm[key]
- })
- }
- this.otaLoading = true;
- const { code } = await otaSave(postList);
- if (code === 200) {
- this.$message.success("操作成功!");
- this.getList();
- this.visibleStatus = false;
- }
- } catch (error) {
- } finally {
- this.otaLoading = false;
- }
- }
- });
- },
- }
- };
- </script>
|