<template>
<div>
  <el-dialog append-to-body :close-on-click-modal="false" :title="titlePConut" width="600px" :visible.sync="dialogFormVisible">
    <el-form>
      <el-form-item label="P数类型" label-width="100px">
        <el-radio-group v-model="pcountType">
          <el-radio style="margin-bottom: 8px;width: 150px;" v-for="(item,index) in pcountTypeList"
                    :key="index" :label="item.id">{{item.priceName}}</el-radio>

        </el-radio-group>
      </el-form-item>
      <el-form-item label="订单P数" label-width="100px">
        <el-input autofocus=true ref="inputPCount" v-model="PCount" @keyup.enter.native="editPCount" oninput = "value=Number(value.replace(/[^\d.]/g,''))" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogFormVisible = false">取 消</el-button>
      <el-button type="primary" @click="editPCount">确 定</el-button>
    </div>
  </el-dialog>
</div>
</template>

<script>
import {getProductPagePriceList} from "@/api/productFile/pagePrice";
import {editImageDispatchItemPCount} from "@/api/specialEdition/fileHandle";

export default {
  name: "pcountEdit",
  data() {
    return {
      rowId:"",
      PCount: '',
      pcountType:"",
      pcountTypeList:[],
      dialogFormVisible:false,
      titlePConut:"",
    }
  },
  mounted() {
    // this.getPcountTypeList();
  },
  methods: {
    getPcountTypeList(){
      var _that = this;
      var params = {}
      var data = {
        'params': JSON.stringify(params),
        // 'page': JSON.stringify(page)
      }
      // console.log(data);
      getProductPagePriceList(data).then(response => {
        // console.log('基础纸张档案列表',response)
        const data = response.data
        // //  组合表单数据
        _that.pcountTypeList = data;
        this.$nextTick(() => {
          _that.$refs.inputPCount.focus()
        })
        // console.log(_that.tableData)
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    editPCount(){
      var _that = this;
      _that.dialogFormVisible = false;
      var data = {
        "id": _that.rowId,
        "pCount": _that.PCount,
        "itemKind":_that.pcountType
      }
      editImageDispatchItemPCount(data).then(response => {
        // console.log(response)
        if (response.httpCode == 200) {
          _that.$message.success("修改成功");
          _that.dialogFormVisible = false;
          _that.$emit('getList',1)
        }

      }).catch(err => {
        _that.dialogFormVisible = false;
        _that.$message.error(err)
      })
    },
  }
}
</script>

<style scoped>

</style>
