<template>
	<div class="app-container">
		<el-form ref="form" :model="form" :rules="rules" label-width="100px">
            <el-card shadow="never">
                <div slot="header" class="clearfix">
                    <span>基本信息</span>
                </div>
                <el-form-item label="仓库ID字符串" prop="warehouseIds">
                    <el-input
                        v-model="form.warehouseIds"
                        placeholder="请输入仓库ID字符串"
                    />
                </el-form-item>
                <el-form-item label="快递ID" prop="expressId">
                    <el-input v-model="form.expressId" placeholder="请输入快递ID" />
                </el-form-item>
                <el-form-item label="渠道代理" prop="channelAgent">
                    <el-input
                        v-model="form.channelAgent"
                        placeholder="请输入渠道代理"
                    />
                </el-form-item>
            </el-card>
            <el-card shadow="never">
                <div slot="header" class="clearfix">
                    <span>渠道收费规则</span>
                </div>
                <!-- <el-form-item label="渠道ID" prop="channelId">
                    <el-input v-model="form.channelId" placeholder="请输入渠道ID" />
                </el-form-item> -->
                <el-form-item label="收费模式" prop="chargingMode">
                    <el-input v-model="form.channelCostCreateReqVO.chargingMode" placeholder="请输入收费模式" />
                </el-form-item>
                <el-form-item label="是否包税：0 不包税 1 包税" prop="isTaxInclusive">
                    <el-input v-model="form.channelCostCreateReqVO.isTaxInclusive" placeholder="请输入是否包税：0 不包税 1 包税" />
                </el-form-item>
                <el-form-item label="包税加价金额" prop="taxAddAmount">
                    <el-input v-model="form.channelCostCreateReqVO.taxAddAmount" placeholder="请输入包税加价金额" />
                </el-form-item>
                <el-form-item label="结算类型：1 单件 2 整票" prop="settlementType">
                    <el-select v-model="form.channelCostCreateReqVO.settlementType" placeholder="请选择结算类型：1 单件 2 整票">
                        <el-option label="请选择字典生成" value="" />
                    </el-select>
                </el-form-item>
                <el-form-item label="免税金额" prop="taxFreeAmount">
                    <el-input v-model="form.channelCostCreateReqVO.taxFreeAmount" placeholder="请输入免税金额" />
                </el-form-item>
                <el-form-item label="消费税比例" prop="consumptionTaxRatio">
                    <el-input v-model="form.channelCostCreateReqVO.consumptionTaxRatio" placeholder="请输入消费税比例" />
                </el-form-item>
                <el-form-item label="燃油费用比例" prop="fuelCostRatio">
                    <el-input v-model="form.channelCostCreateReqVO.fuelCostRatio" placeholder="请输入燃油费用比例" />
                </el-form-item>
                <el-form-item label="单件取整重量" prop="oneRoundingWeight">
                    <el-input v-model="form.channelCostCreateReqVO.oneRoundingWeight" placeholder="请输入单件取整重量" />
                </el-form-item>
                <el-form-item label="取整单价" prop="unitPrice">
                    <el-input v-model="form.channelCostCreateReqVO.unitPrice" placeholder="请输入取整单价" />
                </el-form-item>
                <el-form-item label="杂费" prop="incidental">
                    <el-input v-model="form.channelCostCreateReqVO.incidental" placeholder="请输入杂费" />
                </el-form-item>
                <el-form-item label="免抛重量" prop="freeThrowWeight">
                    <el-input v-model="form.channelCostCreateReqVO.freeThrowWeight" placeholder="请输入免抛重量" />
                </el-form-item>
                <el-form-item label="计算系数" prop="coefficients">
                    <el-input v-model="form.channelCostCreateReqVO.coefficients" placeholder="请输入计算系数" />
                </el-form-item>
                <el-form-item label="清关单价" prop="customsClearUnit">
                    <el-input v-model="form.channelCostCreateReqVO.customsClearUnit" placeholder="请输入清关单价" />
                </el-form-item>
            </el-card>
            <el-card shadow="never">
                <div slot="header" class="clearfix">
                    <span>渠道信息</span>
                </div>
                <el-row>
                    <el-col span="12">
                        <el-form-item label="中文名称" prop="nameZh">
                            <el-input v-model="form.nameZh" placeholder="请输入名称-中文" />
                        </el-form-item>
                    </el-col>
                    <el-col span="12">
                        <el-form-item label="名称英文" prop="nameEn">
                            <el-input v-model="form.nameEn" placeholder="请输入名称-英文" />
                        </el-form-item>
                    </el-col>
                    <el-col span="12">
                        <el-form-item label="内部名称中文" prop="internalNameZh">
                            <el-input
                                v-model="form.internalNameZh"
                                placeholder="请输入内部名称-中文"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col span="12">
                        <el-form-item label="内部名称英文" prop="internalNameEn">
                            <el-input
                                v-model="form.internalNameEn"
                                placeholder="请输入内部名称-英文"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-form-item label="类型编码" prop="typeNumber">
                    <el-input
                        v-model="form.typeNumber"
                        placeholder="请输入类型编码"
                    />
                </el-form-item>
                <el-form-item label="排序" prop="sort">
                    <el-input v-model="form.sort" placeholder="请输入排序" />
                </el-form-item>
                <el-form-item label="预计到达时间(天)" prop="etaTime">
                    <el-date-picker
                        clearable
                        v-model="form.etaTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择预计到达时间(天)"
                    />
                </el-form-item>
                <el-form-item label="备注-中文" prop="remarksZh">
                    <el-input
                        v-model="form.remarksZh"
                        placeholder="请输入备注-中文"
                    />
                </el-form-item>
                <el-form-item label="备注-英文" prop="remarksEn">
                    <el-input
                        v-model="form.remarksEn"
                        placeholder="请输入备注-英文"
                    />
                </el-form-item>
                <el-form-item label="状态(0:禁用 1:启用)" prop="status">
                    <el-radio-group v-model="form.status">
                        <el-radio label="1">请选择字典生成</el-radio>
                    </el-radio-group>
                </el-form-item>
            </el-card>
		</el-form>
		<div slot="footer" class="dialog-footer">
			<el-button type="primary" @click="submitForm">确 定</el-button>
			<el-button @click="cancel">取 消</el-button>
		</div>
	</div>
</template>
<script>
import {
	createChannel,
	updateChannel,
	deleteChannel,
	getChannel,
	getChannelPage,
	exportChannelExcel,
} from "@/api/ecw/channel";

export default {
	data() {
		return {
			form: {
                channelCostCreateReqVO:{}
            },
			rules: {},
		};
	},
	created() {
		if (this.$route.query.id) {
			getChannel(this.$route.query.id).then((res) => {
				this.form = res.data;
			});
		}
	},
	methods: {
		/** 提交按钮 */
		submitForm() {
			this.$refs["form"].validate((valid) => {
				if (!valid) {
					return;
				}
				// 修改的提交
				if (this.form.channelId != null) {
					updateChannel(this.form).then((response) => {
						this.$modal.msgSuccess("修改成功");
						this.open = false;
						this.getList();
					});
					return;
				}
				// 添加的提交
				createChannel(this.form).then((response) => {
					this.$modal.msgSuccess("新增成功");
					this.open = false;
					this.getList();
				});
			});
		},
	},
};
</script>
<style scoped lang="scss">
.el-card{
    margin-bottom: 20px;
}
</style>