a
<template>
  <div class="app-container">
    <div class="header" style="width: 100%">
      <el-row class="row" :gutter="12">
        <el-col :span="4">
          <el-card shadow="always">
            <div class="item">
              <div style="padding: 10px">
                <span>已完成订单</span>
              </div>
              <div class="count">0</div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always">
            <div class="item">
              <div style="padding: 10px">
                <span>到账金额</span>
              </div>
              <div class="count">0</div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="4">
          <el-card shadow="always">
            <div class="item">
              <div style="padding: 10px">
                <span>冻结金额</span>
              </div>
              <div class="count">0</div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="80px"
    >
      <el-form-item label="订单编号" prop="configName">
        <el-input
          v-model="queryParams.configName"
          placeholder="请输入订单编号"
          clearable
          style="width: 180px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="下单人手机号/姓名" prop="configName" label-width="140px">
        <el-input
          v-model="queryParams.configName"
          placeholder="请输入下单用户手机号/姓名"
          clearable
          style="width: 180px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="下单时间" prop="configType">
        <el-date-picker v-model="value1" type="date" placeholder="请选择下单时间">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="交易状态">
        <el-select v-model="value" placeholder="请选择交易状态" style="width: 180px">
          <el-option :label="1" :value="1"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="支付方式">
        <el-select v-model="value" placeholder="请选择支付方式" style="width: 180px">
          <el-option :label="1" :value="1"> </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="printOrder"
          >订单打印</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="printOrder">导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" @click="All"
          >全选</el-button
        >
      </el-col>
    </el-row>

    <el-table
      v-loading="loading"
      :data="configList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="订单编号" align="center" prop="configId" />
      <el-table-column
        label="商品名称"
        align="center"
        prop="configName"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="单价/数量" align="center" prop="configKey" />
      <el-table-column label="实付款" align="center" prop="configValue" />
      <el-table-column label="下单时间" align="center" prop="configValue" />
      <el-table-column label="付款时间" align="center" prop="configValue" />
      <el-table-column label="买家信息" align="center" prop="configType">
        <template slot-scope="scope"> </template>
      </el-table-column>
      <el-table-column label="支付方式" align="center" prop="remark" />
      <el-table-column label="配送方式" align="center" prop="remark" />
      <el-table-column label="交易状态" align="center" prop="createTime" width="180">
        <template slot-scope="scope"> </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['manage:order:detail']"
            >订单详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改参数配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-descriptions title="订单详情" column="3">
        <el-descriptions-item label="订单编号">kooriookami</el-descriptions-item>
        <el-descriptions-item label="订单状态">18100000000</el-descriptions-item>
        <el-descriptions-item label="配送方式">苏州市</el-descriptions-item>
        <el-descriptions-item label="支付方式"> </el-descriptions-item>
        <el-descriptions-item label="下单时间"> 1188 号</el-descriptions-item>
        <el-descriptions-item label="付款时间"> </el-descriptions-item>
        <el-descriptions-item label="担保服务费"> </el-descriptions-item>
        <el-descriptions-item label="运费"> </el-descriptions-item>
        <el-descriptions-item label="实付款"> </el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="物流信息" column="3">
        <el-descriptions-item label="运单号">kooriookami</el-descriptions-item>
        <el-descriptions-item label="司机">18100000000</el-descriptions-item>
        <el-descriptions-item label="车型">苏州市</el-descriptions-item>
        <el-descriptions-item label="车牌号"> </el-descriptions-item>
        <el-descriptions-item label="司机电话"> 1188 号</el-descriptions-item>
        <el-descriptions-item label="装货时间"> </el-descriptions-item>
        <el-descriptions-item label="送达时间"> </el-descriptions-item>
      </el-descriptions>
      <el-descriptions title="买家信息" column="3">
        <el-descriptions-item label="昵称">kooriookami</el-descriptions-item>
        <el-descriptions-item label="头像">18100000000</el-descriptions-item>
        <el-descriptions-item label="收货人">苏州市</el-descriptions-item>
        <el-descriptions-item label="手机号"> </el-descriptions-item>
        <el-descriptions-item label="备注"> 1188 号</el-descriptions-item>
        <el-descriptions-item label="收货地址"> </el-descriptions-item> </el-descriptions
      >、
      <el-descriptions title="商品信息" column="3"> </el-descriptions>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column label="序号" align="center">
          <template slot-scope="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>
        <el-table-column prop="date" label="商品图片"> </el-table-column>
        <el-table-column prop="name" label="商品名称"> </el-table-column>
        <el-table-column prop="name" label="商品单价"> </el-table-column>
        <el-table-column prop="name" label="下单数量"> </el-table-column>
        <el-table-column prop="price" label="总金额"> </el-table-column>
        <el-table-column prop="price" label="实付款"> </el-table-column>
      </el-table>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listConfig,
  getConfig,
  delConfig,
  addConfig,
  updateConfig,
  refreshCache,
} from "@/api/system/config";

export default {
  name: "Config",
  //   dicts: ["sys_yes_no"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 参数表格数据
      configList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        configName: undefined,
        configKey: undefined,
        configType: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        configName: [{ required: true, message: "参数名称不能为空", trigger: "blur" }],
        configKey: [{ required: true, message: "参数键名不能为空", trigger: "blur" }],
        configValue: [{ required: true, message: "参数键值不能为空", trigger: "blur" }],
      },
    };
  },
  created() {
    // this.getList();
  },
  methods: {
    /** 查询参数列表 */
    getList() {
      this.loading = true;
      listConfig(this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
        this.configList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        configId: undefined,
        configName: undefined,
        configKey: undefined,
        configValue: undefined,
        configType: "Y",
        remark: undefined,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加参数";
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.configId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const configId = row.configId || this.ids;
      getConfig(configId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改参数";
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.configId != undefined) {
            updateConfig(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addConfig(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const configIds = row.configId || this.ids;
      this.$modal
        .confirm('是否确认删除参数编号为"' + configIds + '"的数据项？')
        .then(function () {
          return delConfig(configIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/config/export",
        {
          ...this.queryParams,
        },
        `config_${new Date().getTime()}.xlsx`
      );
    },
    /** 刷新缓存按钮操作 */
    handleRefreshCache() {
      refreshCache().then(() => {
        this.$modal.msgSuccess("刷新成功");
      });
    },
  },
};
</script>
<style scoped lang="scss">
.header {
  margin-bottom: 30px;
  .item {
    height: 100px;
  }
  .row {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    .count {
      padding: 10px;
      font-size: 23px;
      font-weight: 500;
    }
    .zz {
      font-size: 14px;
      color: red;
      padding: 0px 10px;
    }
  }
}
</style>
