<template>
    <div class="testdiv">
        <div class="divborder newSearchDiv" style="margin: 0px">
            <div>
                <div class="filter">
                    <label>{{ $t(600570) }}：</label>
                    <Input
                        class="searchInput"
                        type="text"
                        v-model="chinaname"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600575) }}：</label>
                    <Select
                        v-model="Industrycategory"
                        label-in-value
                        @on-change="Industrychange"
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in Industrylist"
                            :value="item.id"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="Industrycategoryson"
                        label-in-value
                        clearable
                        class="searchSelect"
                        style="margin-left: 10px"
                    >
                        <Option
                            v-for="item in Industrysonlist"
                            :value="item.id"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                </div>
                <div class="filter">
                    <label>{{ $t(1131) }}：</label>
                    <Select
                        v-model="province"
                        label-in-value
                        @on-change="provincechange(province)"
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in provincelist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="city"
                        label-in-value
                        @on-change="citychange(city)"
                        clearable
                        class="searchSelect"
                        style="margin-left: 10px"
                    >
                        <Option
                            v-for="item in citylist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="county"
                        label-in-value
                        clearable
                        class="searchSelect"
                        style="margin-left: 10px"
                    >
                        <Option
                            v-for="item in countylist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                </div>
            </div>

            <div class="searchBtn">
                <Button
                    type="primary"
                    class="twoWord"
                    icon="ios-search"
                    @click="search(1, 10)"
                    >{{ $t("1001") }}</Button
                >
                <Button
                    type="success"
                    class="twoWord"
                    icon="md-add-circle"
                    @click="add()"
                    >{{ $t("1002") }}</Button
                >
                <Button
                    type="warning"
                    class="twoWord"
                    icon="ios-create-outline"
                    @click="edit()"
                    >{{ $t("1003") }}</Button
                >
                <Button
                    type="error"
                    class="twoWord"
                    icon="md-close-circle"
                    @click="asyncDelete()"
                    >{{ $t("1004") }}</Button
                >
            </div>
        </div>
        <div class="divborder newTableDiv">
            <Table
                @on-current-change="handleRowChange"
                highlight-row
                :data="tableData1"
                :columns="tableColumns1"
                class="tableClass"
            ></Table>
            <div class="pageDiv">
                <div class="pageDirection">
                    <Page
                        :total="total"
                        :current="page"
                        @on-change="changePage"
                        show-elevator
                        show-sizer
                        show-total
                        @on-page-size-change="handlePageSize"
                        :page-size-opts="[10, 20, 30, 40, 100]"
                    ></Page>
                </div>
            </div>
            <Modal
                :title="$t(1002)"
                v-model="addmodal"
                :styles="{ width: '680px' }"
                class="newModalClass"
            >
                <div class="filter">
                    <label> <i>*</i>CID： </label>
                    <Input
                        class="searchInput"
                        type="number"
                        id="input1"
                        v-model="addId"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600570) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addName"
                        required="required"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600571) }}：</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addPinyin"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(1131) }}：
                    </label>

                    <Select
                        v-model="addProvince"
                        label-in-value
                        @on-change="provincechange(addProvince)"
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in provincelist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="addCity"
                        label-in-value
                        @on-change="citychange(addCity)"
                        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="addArea"
                        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"
                        id="input1"
                        v-model="addAddr"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600573) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addContacts"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600574) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="tel"
                        id="input1"
                        v-model="addPhone"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(100007) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="email"
                        id="input1"
                        v-model="addEmail"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600575) }}：</label>
                    <Select
                        v-model="addIndustrycategory"
                        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="addIndustrycategorySon"
                        label-in-value
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in Industrysonlist"
                            :value="item.id"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                </div>
                <div class="filter">
                    <label>{{ $t(100044) }}：</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addDesc"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600577) }}：</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addCompanyCode"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(1219) }}：</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="addWebsite"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600579) }}：</label>
                    <Select
                        v-model="addIsConfrn"
                        label-in-value
                        clearable
                        class="searchSelect"
                    >
                        <Option value="未认证">{{ $t(600580) }}</Option>
                        <Option value="已认证">{{ $t(600581) }}</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 slot="footer">
                    <Button
                        type="text"
                        size="large"
                        @click="addmodal = false"
                        v-text="$t(1033)"
                        >取消</Button
                    >
                    <Button
                        type="primary"
                        size="large"
                        @click="asyncAdd"
                        v-text="$t(1011)"
                        >确定</Button
                    >
                </div>
            </Modal>
            <Modal
                :title="$t(1003)"
                v-model="editmodal"
                :styles="{ width: '680px' }"
                class="newModalClass"
            >
                <div class="filter">
                    <label> <i>*</i>CID： </label>
                    <Input
                        class="searchInput"
                        readonly
                        disabled
                        type="number"
                        id="input1"
                        v-model="detailobj.id"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600570) }}；
                    </label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.chinesename"
                        required="required"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600571) }}:</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.chinesepinyin"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(1131) }}：
                    </label>
                    <Select
                        v-model="editprovincex"
                        label-in-value
                        @on-change="provincechange(editprovincex)"
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in provincelist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="editcityx"
                        label-in-value
                        @on-change="citychange(editcityx)"
                        clearable
                        class="searchSelect"
                        style="margin-left: 10px"
                    >
                        <Option
                            v-for="item in editcitylist"
                            :value="item.code"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                    <Select
                        v-model="editcountyx"
                        label-in-value
                        clearable
                        class="searchSelect"
                        style="margin-left: 10px"
                    >
                        <Option
                            v-for="item in editcountylist"
                            :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"
                        id="input1"
                        v-model="detailobj.detailaddress"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600573) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.contact"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(600574) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="tel"
                        id="input1"
                        v-model="detailobj.telephone"
                        placeholder="请输入电话"
                    />
                </div>
                <div class="filter">
                    <label>
                        <i>*</i>
                        {{ $t(100007) }}：
                    </label>
                    <Input
                        class="searchInput"
                        type="email"
                        id="input1"
                        v-model="detailobj.email"
                        placeholder="请输入邮箱"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600575) }}:</label>
                    <Select
                        v-model="detailobj.industry_first"
                        label-in-value
                        @on-change="editIndustrychange"
                        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="detailobj.industry_second"
                        label-in-value
                        clearable
                        class="searchSelect"
                    >
                        <Option
                            v-for="item in Industrysonlist"
                            :value="item.id"
                            :key="item.id"
                            >{{ item.name }}</Option
                        >
                    </Select>
                </div>
                <div class="filter">
                    <label>{{ $t(100044) }}:</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.description"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600577) }}:</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.companycode"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(1219) }}:</label>
                    <Input
                        class="searchInput"
                        type="text"
                        id="input1"
                        v-model="detailobj.website"
                    />
                </div>
                <div class="filter">
                    <label>{{ $t(600579) }}:</label>
                    <Select
                        v-model="detailobj.identificat"
                        label-in-value
                        clearable
                        class="searchSelect"
                    >
                        <Option value="未认证">{{ $t(600580) }}</Option>
                        <Option value="已认证">{{ $t(600581) }}</Option>
                    </Select>
                </div>
                <div style="display: flex">
                    <label>{{ $t(600528) }}：</label>
                    <div class="uploadMax">
                        <img :src="detailobj.litpic" alt />
                        <input
                            class="editimg_input"
                            type="file"
                            name
                            ref="fileInteditimg"
                            id
                            @change="editunloadimg"
                            accept="image/png, image/gif, image/jpeg"
                        />
                    </div>
                </div>
                <div slot="footer">
                    <Button
                        type="text"
                        size="large"
                        @click="editmodal = false"
                        v-text="$t(1033)"
                        >取消</Button
                    >
                    <Button
                        type="primary"
                        size="large"
                        @click="asyncEdit"
                        v-text="$t(1011)"
                        >确定</Button
                    >
                </div>
            </Modal>
        </div>
    </div>
</template>
<script>
import axios from "@/libs/api.request";
export default {
    name: "Businessmanagement", // 组件不刷新
    data() {
        return {
            morecondition: false,
            chinaname: "",
            Industrycategory: "",
            Industrylist: [],
            Industrycategoryson: "",
            Industrysonlist: [],
            province: "",
            provincelist: [],
            city: "",
            citylist: [],
            addcitylist: [],
            editcitylist: [],
            county: "",
            countylist: [],
            addcountylist: [],
            editcountylist: [],
            tableData1: [],
            total: 0,
            page: 1,
            pagesize: 10,
            addmodal: false,
            editmodal: false,
            addObj: {},
            detailobj: {},
            addId: "",
            addName: "",
            addPinyin: "",
            addIndustrycategory: "",
            addIndustrycategorySon: "",
            addDesc: "",
            addCompanyCode: "",
            addWebsite: "",
            addIsConfrn: "",
            addProvince: "",
            addCity: "",
            addArea: "",
            addAddr: "",
            addContacts: "",
            addPhone: "",
            addEmail: "",
            addCommit: false,
            editprovincex: "",
            editcityx: "",
            editcountyx: "",
            // 克隆对象
            tableRowObj: {},
            loadimg: require("../../../static/images/xiangjitwo.png"),
            editloadimg: require("../../../static/images/xiangjitwo.png"),
            tableColumns1: [
                {
                    type: "index2",
                    title: this.$t(1008),
                    key: "xuhao",
                    width: 80,
                    render: (h, params) => {
                        return h(
                            "span",
                            params.index + (this.page - 1) * this.pagesize + 1
                        );
                    },
                },
                {
                    title: "CID",
                    key: "id",
                },
                {
                    title: this.$t(600570),
                    key: "chinesename",
                },
                {
                    title: this.$t(600571),
                    key: "chinesepinyin",
                },
                {
                    title: this.$t(600319),
                    key: "companycode",
                },
                {
                    title: this.$t(100044),
                    key: "description",
                },
                {
                    title: this.$t(600320),
                    key: "provinceTitle",
                },
                {
                    title: this.$t(600321),
                    key: "cityTitle",
                },
                {
                    title: this.$t(1131),
                    key: "countyTitle",
                },
                {
                    title: this.$t(920171),
                    key: "detailaddress",
                },
                {
                    title: this.$t(600573),
                    key: "contact",
                },
                {
                    title: this.$t(600574),
                    key: "telephone",
                },
                {
                    title: this.$t(100007),
                    key: "email",
                },
            ],
            litpic: "",
        };
    },
    created() {
        this.initIndustry();
        this.initprovince();
        this.search(1, 10);
        // 格式化表格样式
        this.tableColumns1 = this.$time.initTableTitle(this.tableColumns1);
    },
    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));
                    }
                });
        },
        changecondition() {
            this.morecondition = !this.morecondition;
        },
        addIndustrychange() {
            var params = { firstid: this.addIndustrycategory };
            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));
                    }
                });
        },
        editIndustrychange() {
            var params = { firstid: this.detailobj.industry_first };
            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));
                    }
                });
        },
        Industrychange() {
            var params = { firstid: this.Industrycategory };
            axios
                .request({
                    url: "config/Industry/GetIndustrySecond",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.Industrysonlist = res.data.data;
                    }
                });
        },
        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(province) {
            var params = {
                type: 2,
                status: 1,
                province_code: province,
            };
            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(city) {
            var params = {
                type: 3,
                status: 1,
                city_code: city,
            };
            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));
                    }
                });
        },
        search(page, pagesize) {
            var params = {
                page: page,
                pagesize: pagesize,
                province: this.province,
                chinesename: this.chinaname,
                city: this.city,
                county: this.county,
                industry_first: this.Industrycategory,
                industry_second: this.Industrycategoryson,
            };
            axios
                .request({
                    url: "/config/company/Getcompanylist",
                    params,
                    method: "get",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.total = res.data.total;
                        this.mockTableData1(res.data.data);
                        // this.detailobj = {}
                        this.page = res.data.page;
                    }
                });
        },
        mockTableData1(tablelist) {
            let data = [];
            tablelist.forEach((item) => {
                if (item) {
                    data.push({
                        id: item.id,
                        chinesename: item.chinesename,
                        chinesepinyin: item.chinesepinyin,
                        province: item.province,
                        provinceTitle: item.provinceTitle,
                        city: item.city,
                        cityTitle: item.cityTitle,
                        county: item.county,
                        countyTitle: item.countyTitle,
                        detailaddress: item.detailaddress,
                        contact: item.contact,
                        telephone: item.telephone,
                        email: item.email,
                        industry: item.industry,
                        industry_first: item.industry_first,
                        industry_second: item.industry_second,
                        description: item.description,
                        website: item.website,
                        litpic: item.litpic,
                        identificat: item.identification,
                        companycode: item.companycode,
                    });
                }
            });
            this.tableData1 = data;
        },
        handlePageSize(value) {
            this.pagesize = value;
            this.tableData1 = this.search(this.page, this.pagesize);
        },
        changePage(value) {
            this.page = value;
            this.tableData1 = this.search(this.page, this.pagesize);
        },
        handleRowChange(currentRow, oldCurrentRow) {
            this.detailobj = currentRow;
            this.tableRowObj = this.$time.deepClone(currentRow);
            this.editIndustrychange();
        },
        add() {
            this.addIsConfrn = "未认证";

            this.addmodal = true;
        },
        asyncAdd() {
            if (this.addId === "") {
                this.$Message.error(this.$t(600654));
                return false;
            } else if (this.addName === "") {
                this.$Message.error(this.$t(600655));
                return false;
            } else if (this.addArea === "") {
                this.$Message.error(this.$t(600653));
                return false;
            } else if (this.addAddr === "") {
                this.$Message.error(this.$t(600656));
                return false;
            } else if (this.addContacts === "") {
                this.$Message.error(this.$t(600657));
                return false;
            } else if (this.addPhone === "") {
                this.$Message.error(this.$t(600658));
                return false;
            } else if (
                !/^1([38][0-9]|4[579]|5[0-3,5-9]|6[6]|7[0135678]|9[89])\d{8}$/.test(
                    this.addPhone
                )
            ) {
                this.$Message.error(this.$t(666621));
                return false;
            } else if (this.addEmail === "") {
                this.$Message.error(this.$t(600659));
                return false;
            } else {
                this.addCommit = true;
            }
            if (this.addCommit === false) {
                return false;
            }
            if (
                this.loadimg == require("../../../static/images/xiangjitwo.png")
            ) {
                this.loadimg = "";
            }
            var data = {
                cid: this.addId,
                chinesename: this.addName,
                chinesepinyin: this.addPinyin,
                province: this.addProvince,
                city: this.addCity,
                county: this.addArea,
                detailaddress: this.addAddr,
                telephone: this.addPhone,
                website: this.addWebsite,
                contact: this.addContacts,
                email: this.addEmail,
                industry_first: this.addIndustrycategory,
                industry_second: this.addIndustrycategorySon,
                litpic: this.litpic,
                description: this.addDesc,
                companycode: this.addCompanyCode,
                identification: this.addIsConfrn,
            };
            axios
                .request({
                    url: "/config/company/AddCompany",
                    data,
                    method: "post",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t(1055));
                        this.search(1, 10);
                        this.addId = "";
                        this.addName = "";
                        this.addPinyin = "";
                        this.addProvince = "";
                        this.addCity = "";
                        this.addArea = "";
                        this.addAddr = "";
                        this.addPhone = "";
                        this.addWebsite = "";
                        this.addContacts = "";
                        this.addEmail = "";
                        this.addIndustrycategory = "";
                        this.addIndustrycategorySon = "";
                        (this.loadimg = require("../../../static/images/xiangjitwo.png")),
                            (this.addDesc = "");
                        this.addCompanyCode = "";
                        this.addIsConfrn = "";
                        this.addmodal = false;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },

        asyncEdit() {
            if (this.detailobj.id === "") {
                this.$Message.error(this.$t(600654));
                return false;
            } else if (this.detailobj.chinesename === "") {
                this.$Message.error(this.$t(600655));
                return false;
            } else if (this.editprovincex === "") {
                this.$Message.error(this.$t(600653));
                return false;
            } else if (this.detailobj.detailaddress === "") {
                this.$Message.error(this.$t(600656));
                return false;
            } else if (this.detailobj.contact === "") {
                this.$Message.error(this.$t(600657));
                return false;
            } else if (this.detailobj.telephone === "") {
                this.$Message.error(this.$t(600658));
                return false;
            } else if (this.detailobj.province === undefined) {
                this.$Message.error(this.$t(600653));
                return false;
            } else if (this.detailobj.city === undefined) {
                this.$Message.error(this.$t(600653));
                return false;
            } else if (this.detailobj.county === undefined) {
                this.$Message.error(this.$t(600653));
                return false;
            } else {
            }
            if (
                this.detailobj.litpic ==
                require("../../../static/images/xiangjitwo.png")
            ) {
                this.detailobj.litpic = "";
            }
            // console.log((this.this.detailobj.litpic==require('../../../static/images/xiangjitwo.png'))?1:2)
            // this.detailobj.litpic=((this.this.detailobj.litpic==require('../../../static/images/xiangjitwo.png'))?'':this.detailobj.litpic)
            // console.log(this.detailobj.litpic)
            var data = {
                id: this.detailobj.id,
                chinesename: this.detailobj.chinesename,
                chinesepinyin: this.detailobj.chinesepinyin,
                province: this.editprovincex,
                city: this.editcityx,
                county: this.editcountyx,
                detailaddress: this.detailobj.detailaddress,
                telephone: this.detailobj.telephone,
                website: this.detailobj.website,
                contact: this.detailobj.contact,
                email: this.detailobj.email,
                industry_first: this.detailobj.industry_first,
                industry_second: this.detailobj.industry_second,
                litpic: this.detailobj.litpic,
                description: this.detailobj.description,
                companycode: this.detailobj.companycode,
                identification: this.detailobj.identificat,
            };
            console.log(data);

            axios
                .request({
                    url: "/config/company/EditCompany",
                    data,
                    method: "post",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t(90000054));

                        this.editloadimg = require("../../../static/images/xiangjitwo.png");
                        this.editmodal = false;
                        this.detailobj = {};
                        this.search(1, 10);
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                });
        },
        // valid () {

        // },
        edit() {
            if (this.detailobj.id == null) {
                this.$Message.error(this.$t(90000081));
                return;
            } else {
                this.detailobj = this.$time.deepClone(this.tableRowObj);
                this.provincechange(this.detailobj.province);
                this.citychange(this.detailobj.city);
            }
            this.editcityx = this.detailobj.city;
            this.editcountyx = this.detailobj.county;
            this.editprovincex = this.detailobj.province;
            if (this.detailobj.litpic == "") {
                this.detailobj.litpic = this.editloadimg;
            }
            this.editmodal = true;
        },
        asyncDelete() {
            if (this.detailobj.id === undefined) {
                this.$Message.error(this.$t(90000081));
                return false;
            } else {
                this.$Modal.confirm({
                    title: this.$t("1018"),
                    content: "",
                    width: "290px",
                    closable: true,
                    okText: this.$t("1004"),
                    onOk: () => {
                        axios
                            .request({
                                url:
                                    "/config/Company/DeleteCompany?id=" +
                                    this.detailobj.id,
                                method: "post",
                            })
                            .then((res) => {
                                if (res.data.ret === 1) {
                                    this.$Message.success(this.$t(1058));
                                    this.detailobj = {};
                                    this.search(1, 10);
                                } else {
                                    this.$Message.error(this.$t(res.data.msg));
                                }
                            });
                    },
                });
            }
        },
        unloadimg() {
            // 上传照片
            const file = this.$refs.fileIntimg.files[0];
            const data = new FormData();
            data.append("file", file);
            axios
                .request({
                    url: "/config/upload/UploadImage",
                    data,
                    method: "post",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t(100378));
                        this.loadimg = axios.publicPath + res.data.data;
                        this.litpic = res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                })
                .catch((err) => {
                    alert(err.msg);
                });
        },
        editunloadimg() {
            // 上传照片
            const file = this.$refs.fileInteditimg.files[0];
            const data = new FormData();
            data.append("file", file);
            axios
                .request({
                    url: "/config/upload/UploadImage",
                    data,
                    method: "post",
                })
                .then((res) => {
                    if (res.data.ret === 1) {
                        this.$Message.success(this.$t(100378));
                        this.detailobj.litpic =
                            axios.publicPath + res.data.data;
                    } else {
                        this.$Message.error(this.$t(res.data.msg));
                    }
                })
                .catch((err) => {
                    alert(err.msg);
                });
        },
    },
};
</script>
<style lang="less" scoped>
</style>
