<template>
    <div>
        <div class="divborder">
            <div style="font-size: 14px">
                <div style="display: block">
                    <label>1、单号编码规则</label><span>：</span>
                    <div class="itembox" style="margin-left: 20px" id="div_one">
                        <P
                            ><span
                                >单号生成规则：单号前缀+YYYYMMDD+000000</span
                            ></P
                        >
                        <P
                            ><span
                                >注意：前缀为两位简码，包括数字和字母，不能为特殊字符，YYYY为年MM为月DD为天，000000为自增序号，可以设置位数</span
                            ></P
                        >
                        <p>
                            <span>入库单号前缀</span
                            ><Input
                                v-model="enterpre"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                                placeholder="SH"
                            />
                        </p>
                        <p>
                            <span>出库单号前缀</span
                            ><Input
                                v-model="outpre"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                                placeholder="SC"
                            />
                        </p>
                        <p>
                            <span>调拨单号前缀</span
                            ><Input
                                v-model="transferpre"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                                placeholder="SC"
                            />
                        </p>
                        <p>
                            <span>系统批次前缀</span
                            ><Input
                                v-model="batchpre"
                                style="width: 100px; margin-left: 20px"
                                placeholder="PC"
                            />
                        </p>
                    </div>
                </div>
                <div class="" style="display: block">
                    <label>2、打印设置</label><span>：</span>
                    <div
                        style="margin-left: 20px; line-height: 40px;width:50%
                        
                        
                        
                        
                        "
                        id="div_two"
                    >
                        <Checkbox style="display: block" v-model="enterbatch">
                            <label><span>入库是否打印批次号</span></label>
                            <span style="margin-left: 20px">打印份数</span>
                            <Input
                                type="number"
                                min="0"
                                v-model="num1"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                            />
                        </Checkbox>
                        <Checkbox style="display: block" v-model="enterorder">
                            <label><span>入库是否打印序号</span></label>
                            <span style="margin-left: 34px">打印份数</span>
                            <Input
                                type="number"
                                min="0"
                                v-model="num2"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                            />
                        </Checkbox>
                        <Checkbox style="display: block" v-model="outbatch">
                            <label><span>出库是否打印批次号</span></label>
                            <span style="margin-left: 20px">打印份数</span>
                            <Input
                                type="number"
                                min="0"
                                v-model="num3"
                                style="width: 100px; margin-left: 20px"
                                class="form-control top_input"
                            />
                        </Checkbox>
                    </div>
                </div>
                <Button  type="primary" @click="save()"> 保存 </Button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            enterpre: "",
            outpre: "",
            transferpre: "",
            batchpre: "",
            enterpre: "",
            enterbatch: false,
            enterorder: false,
            outbatch: false,
            num1: 0,
            num2: 0,
            num3: 0,
        };
    },
    created() {
        this.getsettings();
    },
    methods: {
        getsettings() {
            this.request("/wms/System/GetSettings", "", "get").then((res) => {
                if (res.data.ret == 1) {
                    let obj = res.data.data;
                    this.enterpre = obj.waveHousingPre;
                    this.outpre = obj.waveHouseOutPre;
                    this.transferpre = obj.allocationPre;
                    this.batchpre = obj.systemBatchPre;
                    this.enterbatch =
                        obj.waveHousingPrintBatch == "0" ? false : true;
                    this.enterorder =
                        obj.waveHousingPrintNo == "0" ? false : true;
                    this.outbatch =
                        obj.waveHouseOutPrintBatch == "0" ? false : true;
                    this.num1 = obj.waveHousingPrintBatchCount;
                    this.num2 = obj.waveHousingPrintNoCount;
                    this.num3 = obj.waveHouseOutBatchCount;
                }
            });
        },
        save() {
            //data 0:入库单号前缀
            // 1:出库单号前缀
            // 2:调拨单号前缀
            // 3:系统批次前缀
            // 4:入库是否打印批次号
            // 5:入库是否打印批次号份数
            // 6:入库是否打印序号
            // 7:入库是否打印序号份数
            // 8:出库是否打印批次号
            // 9:出库是否打印批次号份数
            // 10:盘点单前缀
            // 设置的值，根据具体参数验证值类型,
            // 分数：int
            // 前缀：string
            // 是否打印：bool
            var arr = [
                { data: 0, value: this.enterpre },
                { data: 1, value: this.outpre },
                { data: 2, value: this.transferpre },
                { data: 3, value: this.batchpre },
                { data: 4, value: this.enterbatch == true ? 1 : 0 },
                { data: 5, value: this.num1 },
                { data: 6, value: this.enterorder == true ? 1 : 0 },
                { data: 7, value: this.num2 },
                { data: 8, value: this.outbatch == true ? 1 : 0 },
                { data: 9, value: this.num3 },
            ];
            let data = {};
            data.datas = arr;
            this.request("/wms/System/Set", data, "post").then((res) => {
                if (res.data.ret == 1) {
                    this.$Message.success(this.$t(1));
                    this.getsettings();
                } else {
                    this.$Message.error(this.$t(res.data.msg));
                }
            });
        },
        request(url, data, type) {
            if (type == "get") {
                return this.axios
                    .request({
                        url: url,
                        params: data,
                        method: type,
                    })
                    .then((res) => {
                        return res;
                    })
                    .catch((error) => error);
            } else {
                return this.axios
                    .request({
                        url: url,
                        data,
                        method: type,
                    })
                    .then((res) => {
                        return res;
                    })
                    .catch((error) => error);
            }
        },
    },
};
</script>

<style scoped>
.itembox p {
    height: 40px;
    line-height: 40px;
}
</style>