export default {
  name: "user_cards_list",
  data() {
    return {
      catetype:2,////分类这里改
      page: 1,
      total: 0,
      status: 0,
      type: "0",
      keywords:"",
      listData: [],
      loading:false,
      count: {

      },
      rate:0,
      logList:[],
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    addDialogEvent(row) {
      this.add_form.parent_id = row.category_id;
      this.addDialog = true;
    },
    sale_order_rate(){
      this.$prompt('请输入服务比例X%', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({ value }) => {
        this.change_sale_order_rate(value);
      }).catch(() => {
        this.loading = false;
        this.$message({
          type: 'info',
          message: '取消输入'
        });
      });
    },
    addmemo(info){
      this.$prompt('请输入备注', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
      }).then(({ value }) => {
        this.change_sale_order_memo(info,value);
      }).catch(() => {
        this.loading = false;
        this.$message({
          type: 'info',
          message: '取消输入'
        });
      });
    },
    async change_sale_order_memo(info,value)
    {
      var order_id=info.id;
      this.loading = true;
      let res = await this.$post("/api/admin/sale/sale_order_memo",{order_id:order_id,memo:value});
      if (res && res.status === 1) {
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
        this.loading = false;
        this.getList();
      }
      else
      {
        this.loading = false;
      }
    },
    async pay_func(info,value){
      var order_id=info.id;
      this.loading = true;
      let res =await this.$post("/api/admin/sale/order_pay",{order_id:order_id});
      if (res && res.status === 1) {
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
        this.loading = false;
        this.getList();
      }
      else
      {
        this.loading = false;
      }
    },
    async pay(info,value)
    {
      await this.$confirm('确定付款后将不可逆, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.pay_func(info,value);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    async tk_func(info,value)
    {
      var order_id=info.id;
      this.loading = true;
      let res =await this.$post("/api/admin/sale/order_tk",{order_id:order_id});
      if (res && res.status === 1) {
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
        this.loading = false;
        this.getList();
      }
      else
      {
        this.loading = false;
      }
    },
    async tk(info,value)
    {
      this.$confirm('确定退款后将不可逆, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.tk_func(info,value);
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });
    },
    async change_sale_order_rate(value)
    {
      this.loading = true;
      let res = await this.$post("/api/admin/sale/sale_order_rate",{rate:value});
      if (res && res.status === 1) {
        this.$message({
          type: 'success',
          message: '操作成功!'
        });
        this.rate=value;
        this.loading = false;
      }
      else
      {
        this.loading = false;
      }
    },
    async isRemind(info) {
      this.loading = true;
      this.logListFunc(info.id);
      let res = await this.$post("/api/admin/sale/orderRemind", {id: info.id});
      if (res && res.status === 1) {
        this.getList();
        this.loading = false;
      }
      else
      {
        this.loading = false;
      }
    },
    //筛选类型
    async typechange(val) {
      this.page=1;
      this.type=val;
      this.keywords="";
      this.getList();
    },
    //删选状态
    async statuschange(val) {
      this.page=1;
      this.status=val;
      this.keywords="";
      this.getList();
    },
    //搜索删选
    async searchkeywords() {
      this.page=1;
      this.keywords=this.keywords;
      this.getList();
    },
    //获取分类列表
    async logListFunc(sale_id) {
      let where={sale_id:sale_id};
      let res = await this.$post("/api/admin/sale/logList",where);
      this.logList=res.data;
    },
    async getList() {
      const data = {
        page:this.page,
        status:this.status,
        type:this.type,
        keywords:this.keywords,
      };
      let res = await this.$post("/api/admin/sale/order_list", data);
      if (res && res.status === 1) {
        this.listData = res.data.list || [];
        this.total = res.data.total * 1;
        this.count = res.data.count;
        this.rate=res.data.rate;
      }
    },
    handleCurrentChange(val) {
      this.page = val;
      this.getAuditList();
    },
  }

}
