<template>
    <div>
        新项目注册

        <Modal
            class="newModalClass newModalClass1"
            v-model="addmodal"
            :styles="{ width: '640px' }"
        >
            <p slot="header">
                <span v-if="type === 1">{{ $t("1002") }}</span>
                <!-- <span v-if="type === 2">{{ $t("1003") }}</span> -->
            </p>
            <div class="modal_body">
                <div>
                    <div v-show="step == 1">
                        <div>
                            <Button
                                size="large"
                                style="
                                    background-color: #2d8cf0;
                                    color: #fff;
                                    margin-right: 20px;
                                "
                                @click="newClient"
                                >新客户</Button
                            >
                            <Button
                                size="large"
                                style="background-color: #797979; color: #fff"
                                @click="oldClient"
                                >旧客户</Button
                            >
                        </div>
                        <div
                            v-show="businesstype == 1"
                            style="margin-top: 20px"
                        >
                            <div class="filter">
                                <label> <i>*</i> 客户名称： </label>
                                <Select
                                    class="searchSelect"
                                    v-model="cilentDetail.cid"
                                    label-in-value
                                    @on-change="getOldCilent"
                                    clearable
                                >
                                    <Option
                                        v-for="item in companylist"
                                        :value="item.id"
                                        :key="item.id"
                                        >{{ item.chinesename }}</Option
                                    >
                                </Select>
                            </div>
                        </div>
                        <div v-show="businesstype == 0">
                            <div class="stepTitle">客户资料</div>
                            <div class="filter">
                                <label> <i>*</i> 客户名称： </label>
                                <Input
                                    class="searchInput"
                                    type="text"
                                    v-model="cilentDetail.name"
                                    required="required"
                                />
                            </div>
                            <div class="filter">
                                <label>英文名称：</label>
                                <Input
                                    class="searchInput"
                                    type="text"
                                    v-model="cilentDetail.nameEn"
                                />
                            </div>
                            <div class="filter">
                                <label>
                                    <i>*</i>
                                    客户地址：
                                </label>

                                <Select
                                    v-model="cilentDetail.province"
                                    label-in-value
                                    @on-change="provincechange"
                                    clearable
                                    class="searchSelect"
                                >
                                    <Option
                                        v-for="item in provincelist"
                                        :value="item.code"
                                        :key="item.id"
                                        >{{ item.name }}</Option
                                    >
                                </Select>
                                <Select
                                    v-model="cilentDetail.city"
                                    label-in-value
                                    @on-change="citychange"
                                    clearable
                                    class="searchSelect"
                                    style="margin-left: 10px"
                                >
                                    <Option
                                        v-for="item in addcitylist"
                                        :value="item.code"
                                        :key="item.id"
                                        >{{ item.name }}</Option
                                    >
                                </Select>
                                <Select
                                    class="searchSelect"
                                    v-model="cilentDetail.area"
                                    label-in-value
                                    clearable
                                    style="margin-left: 10px"
                                >
                                    <Option
                                        v-for="item in addcountylist"
                                        :value="item.code"
                                        :key="item.id"
                                        >{{ item.name }}</Option
                                    >
                                </Select>
                            </div>
                            <div class="filter">
                                <label>
                                    <i>*</i>
                                    {{ $t(600572) }}：
                                </label>
                                <Input
                                    class="searchInput"
                                    type="text"
                                    v-model="cilentDetail.address"
                                />
                            </div>
                            <div class="filter">
                                <label>
                                    <i>*</i>
                                    {{ $t(600573) }}：
                                </label>
                                <Input
                                    class="searchInput"
                                    type="text"
                                    v-model="cilentDetail.contacts"
                                />
                            </div>
                            <div class="filter">
                                <label>
                                    <i>*</i>
                                    联系电话：
                                </label>
                                <Input
                                    class="searchInput"
                                    type="tel"
                                    v-model="cilentDetail.phone"
                                />
                            </div>
                            <div class="filter">
                                <label> <i>*</i>电子邮箱： </label>
                                <Input
                                    class="searchInput"
                                    type="email"
                                    v-model="cilentDetail.email"
                                />
                            </div>
                            <div class="filter">
                                <label>{{ $t(600577) }}：</label>
                                <Input
                                    class="searchInput"
                                    type="text"
                                    v-model="cilentDetail.companycode"
                                />
                            </div>
                            <div class="filter">
                                <label>{{ $t(600575) }}：</label>
                                <Select
                                    v-model="cilentDetail.industrycategory"
                                    label-in-value
                                    @on-change="addIndustrychange"
                                    clearable
                                    class="searchSelect"
                                >
                                    <Option
                                        v-for="item in Industrylist"
                                        :value="item.id"
                                        :key="item.id"
                                        >{{ item.name }}</Option
                                    >
                                </Select>
                            </div>
                            <div class="filter">
                                <label>{{ $t(1218) }}：</label>
                                <Select
                                    v-model="cilentDetail.industrysecond"
                                    label-in-value
                                    clearable
                                    class="searchSelect"
                                >
                                    <Option
                                        v-for="item in Industrysonlist"
                                        :value="item.id"
                                        :key="item.id"
                                        >{{ item.name }}</Option
                                    >
                                </Select>
                            </div>

                            <div style="display: flex">
                                <label>{{ $t(600528) }}：</label>
                                <div class="uploadMax">
                                    <img :src="loadimg" alt />
                                    <input
                                        type="file"
                                        name
                                        ref="fileIntimg"
                                        id
                                        @change="unloadimg"
                                        accept="image/png, image/gif, image/jpeg"
                                    />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div v-show="step == 2">
                        <p class="stepTitle">项目资料</p>
                        <div class="filter">
                            <label><i>*</i>{{ $t("600539") }}：</label>
                            <Input
                                v-model="projectDetail.title"
                                class="searchInput"
                                type="text"
                            />
                        </div>
                        <div class="filter">
                            <label><i>*</i>{{ $t("900672") }}：</label>
                            <Select
                                v-model="projectDetail.typeid"
                                label-in-value
                                clearable
                                class="searchSelect"
                            >
                                <Option
                                    v-for="item in projecttypelist"
                                    :value="item.id"
                                    :key="item.id"
                                    >{{ item.name }}</Option
                                >
                            </Select>
                        </div>

                        <div class="filter">
                            <label><i>*</i>销售人员：</label>
                            <Select
                                v-model="projectDetail.salesmid"
                                label-in-value
                                clearable
                                class="searchSelect"
                            >
                                <Option
                                    v-for="item in creatorlist"
                                    :value="item.id"
                                    :key="item.id"
                                    >{{ item.nickname }}</Option
                                >
                            </Select>
                        </div>
                        <div class="filter">
                            <label><i>*</i>{{ $t("600543") }}：</label>
                            <Input
                                v-model="projectDetail.realname"
                                class="searchInput"
                                type="text"
                            />
                        </div>
                        <div class="filter">
                            <label><i>*</i>登陆{{ $t("600544") }}：</label>
                            <Input
                                v-model="projectDetail.account"
                                class="searchInput"
                                type="text"
                            />
                        </div>
                        <div class="filter">
                            <label> <i>*</i>登陆{{ $t("1016") }}： </label>
                            <Input
                                v-model="projectDetail.password"
                                class="searchInput"
                                type="password"
                            />
                        </div>
                        <div class="filter">
                            <label>{{ $t("600545") }}：</label>
                            <InputNumber
                                v-model="projectDetail.initialoffer"
                                class="searchInput"
                                :min="0"
                            ></InputNumber>
                        </div>
                        <div class="filter">
                            <label>{{ $t("600546") }}：</label>
                            <InputNumber
                                v-model="projectDetail.finaloffer"
                                :min="0"
                                class="searchInput"
                            >
                            </InputNumber>
                        </div>
                        <div class="filter" style="margin-bottom: 10px">
                            <label>{{ $t("600540") }}：</label>
                            <Input
                                type="textarea"
                                v-model="projectDetail.description"
                                class="MaxWidth"
                                style="vertical-align: text-top"
                                :autosize="{ minRows: 2, maxRows: 2 }"
                            />
                        </div>
                        <!-- <div class="filter">
                            <label><i>*</i>{{ $t("950041") }}：</label>
                            <Select
                                :max-tag-count="8"
                                v-model="addobj.modular"
                                label-in-value
                                clearable
                                class="searchSelect MaxWidth nowropStyle"
                                style="overflow-y: scorll; margin-top: 10px"
                                multiple
                            >
                                <Option
                                    v-for="item in modularlist"
                                    :value="item.value"g
                                    :key="item.id"
                                    >{{ $t(item.name) }}</Option
                                >
                            </Select>
                        </div> -->
                    </div>
                    <div v-show="step == 3">
                        <p class="stepTitle">产线层级</p>
                        <div>
                            <Table
                                highlight-row
                                :data="tableData1"
                                :columns="tableColumns1"
                                :max-height="396"
                                @on-selection-change="getProjectList"
                            ></Table>
                        </div>
                    </div>
                    <div v-show="step == 4">
                        <p class="stepTitle">用户授权管理</p>

                        <div style="margin: 10px; padding-left: 30px">
                            <RadioGroup v-model="licenceobj.type">
                                <Radio
                                    :label="1"
                                    style="
                                        font-size: 16px;
                                        width: 150px !important;
                                    "
                                >
                                    <span>永久授权</span>
                                </Radio>
                                <Radio
                                    :label="2"
                                    style="
                                        font-size: 16px;
                                        width: 150px !important;
                                    "
                                    ><span>按时间授权</span></Radio
                                >
                            </RadioGroup>
                        </div>
                        <div>
                            <div class="filter" style="height: 165px">
                                <label>{{ $t("920020") }}：</label>
                                <Input
                                    v-model="licenceobj.values"
                                    type="textarea"
                                    :autosize="{ minRows: 5, maxRows: 5 }"
                                    placeholder="请输入系统授权码"
                                    class="searchInput MaxWidth"
                                />
                            </div>
                        </div>
                        <div>
                            <div class="filter" style="height: 165px">
                                <label>MySql配置：</label>
                                <Input
                                    v-model="licenceobj.mysql"
                                    type="textarea"
                                    :autosize="{ minRows: 5, maxRows: 5 }"
                                    placeholder="请输入MySQL授权码"
                                    class="searchInput MaxWidth"
                                />
                            </div>
                            <!-- <div class="searchBtn" style="margin-left: 105px">
                                <Button
                                    type="primary"
                                    class="twoWord"
                                    icon="ios-build"
                                    @click="save(1)"
                                    >{{ $t("900306") }}</Button
                                >
                            </div> -->
                        </div>
                    </div>
                    <div v-show="step == 5">
                        <p class="stepTitle">账户创建完成</p>
                        <div>
                            <div>账号已创建成功,去登陆验证功能吧！</div>
                            <div>登录账号：</div>
                            <div>登陆密码：</div>
                        </div>
                    </div>
                </div>
            </div>
            <div slot="footer">
                <Button
                    type="primary"
                    size="large"
                    @click="lastStep"
                    v-show="step != 5 && step > 1"
                    >上一步</Button
                >
                <Button
                    type="primary"
                    size="large"
                    @click="nextStep"
                    v-show="step != 5"
                    >下一步</Button
                >
                <Button
                    type="primary"
                    size="large"
                    @click="addmodal = false"
                    v-show="step == 5"
                    >完成</Button
                >
                <!-- <Button type="text" size="large" @click="cancle">取消</Button> -->
                <!-- <Button
                    type="primary"
                    v-if="type === 1"
                    size="large"
                    @click="adddata(1)"
                    >{{ $t("1002") }}</Button
                >
                <Button
                    type="primary"
                    v-if="type === 2"
                    size="large"
                    @click="adddata(2)"
                    >{{ $t("1003") }}</Button
                > -->
            </div>
        </Modal>
    </div>
</template>

<script>
import axios from "@/libs/api.request";

export default {
    data() {
        return {
            step: 0,
            loadimg: require("../../../static/images/xiangjitwo.png"),
            Industrycategoryson: "",
            Industrysonlist: [],
            province: "",
            provincelist: [],
            Industrylist: [],
            addcitylist: [],
            editcitylist: [],
            county: "",
            countylist: [],
            addcountylist: [],
            cilentDetail: {
                cid: 0,
            },
            projectDetail: {},
            licenceobj: {},
            tableColumns1: [
                {
                    type: "index",
                    title: this.$t("1008"),
                    key: "xuhao",
                    render: (h, params) => {
                        return h("span", params.index + 1);
                    },
                    width: 80,
                },
                {
                    type: "selection",
                    width: 80,
                },
                {
                    title: this.$t("800225"),
                    key: "title",
                },
            ],
            tableData1: [],
            selection: [],
            businesstype: 0,
        };
    },
    created() {},
    methods: {
        initIndustry() {
            axios
                .request({
                    url: "config/Industry/GetIndustryFirst",
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.Industrylist = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        initprovince() {
            var params = {
                type: 1,
                status: 1,
            };
            axios
                .request({
                    url: "config/Location/GetLocation",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.provincelist = res.data.data;
                    }
                });
        },
        provincechange(val) {
            var params = {
                type: 2,
                status: 1,
                province_code: val.value ? val.value : "",
            };
            axios
                .request({
                    url: "config/Location/GetLocation",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        if (this.addmodal) {
                            this.addcitylist = res.data.data;
                        } else if (this.editmodal) {
                            this.editcitylist = res.data.data;
                        } else {
                            this.citylist = res.data.data;
                        }
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        citychange(val) {
            var params = {
                type: 3,
                status: 1,
                city_code: val.value ? val.value : "",
            };
            axios
                .request({
                    url: "config/Location/GetLocation",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        if (this.addmodal) {
                            this.addcountylist = res.data.data;
                        } else if (this.editmodal) {
                            this.editcountylist = res.data.data;
                        } else {
                            this.countylist = res.data.data;
                        }
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        addIndustrychange(val) {
            let id = val.value ? val.value : "";
            var params = { firstid: id };
            axios
                .request({
                    url: "config/Industry/GetIndustrySecond",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.Industrysonlist = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
    },
};
</script>

<style>
</style>