| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <template>
- <!-- 添加供应商 -->
- <div class="article-manager video-icon form-submit" id="shopp-manager">
- <div class="i-layout-page-header">
- <PageHeader class="product_tabs" hidden-breadcrumb>
- <div slot="title" class="acea-row row-middle">
- <router-link :to="{ path: `${roterPre}/supplier/menu/list` }">
- <div class="font-sm after-line">
- <span class="iconfont iconfanhui"></span>
- <span class="pl10">返回</span>
- </div>
- </router-link>
- <span
- v-text="$route.params.id ? '编辑供应商' : '添加供应商'"
- class="mr20 ml16"
- ></span>
- </div>
- </PageHeader>
- </div>
- <Card :bordered="false" dis-hover class="ivu-mt">
- <Form
- class="formValidate mt20"
- ref="formValidate"
- :rules="ruleValidate"
- :model="formValidate"
- :label-width="width"
- :label-position="labelPosition"
- @submit.native.prevent
- >
- <Row :gutter="24" type="flex">
- <Col span="24">
- <FormItem label="供应商名称:" prop="supplier_name">
- <Input
- v-model="formValidate.supplier_name"
- placeholder="请输入供应商名称"
- v-width="460"
- />
- </FormItem>
- </Col>
- <!-- <Row :gutter="24" type="flex"> -->
- <Col span="24">
- <FormItem label="联系人姓名:" prop="name">
- <Input
- v-model="formValidate.name"
- placeholder="请输入联系人姓名"
- v-width="460"
- />
- </FormItem>
- </Col>
- <!-- </Row> -->
- <Col span="24">
- <FormItem label="联系电话:" prop="phone">
- <Input
- v-model="formValidate.phone"
- placeholder="请输入联系电话"
- v-width="460"
- />
- </FormItem>
- </Col>
-
- <Col span="24">
- <FormItem label="省市区地址" prop="addressSelect">
- <Cascader
- :data="addresData"
- :load-data="loadData"
- v-model="formValidate.addressSelect"
- @on-change="addchack"
- v-width="460"
- ></Cascader>
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="供应商地址:" prop="detailed_address">
- <Input
- v-model="formValidate.detailed_address"
- placeholder="请输入供应商地址"
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="供应商邮箱:" prop="email">
- <Input
- v-model="formValidate.email"
- placeholder="请输入供应商邮箱"
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="备注:" prop="mark">
- <Input
- type="textarea"
- v-model="formValidate.mark"
- placeholder="请输入..."
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="供应商登录用户名:" prop="account">
- <Input
- v-model="formValidate.account"
- placeholder="请输入登录名称"
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="供应商登录密码 :" prop="pwd">
- <Input
- v-model="formValidate.pwd"
- placeholder="请输入登录密码"
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="确认登录密码 :" prop="conf_pwd">
- <Input
- v-model="formValidate.conf_pwd"
- placeholder="请确认登录密码"
- v-width="460"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="派单限额:">
- <InputNumber
- v-width="460"
- :min="0"
- v-model="formValidate.dispatch_total"
- placeholder="请输入派单限额"
- />
- </FormItem>
- </Col>
- <Col span="24">
- <FormItem label="排序:">
- <InputNumber
- v-width="460"
- :min="0"
- :max="999999"
- v-model="formValidate.sort"
- placeholder="请输入排序"
- />
- </FormItem>
- </Col>
-
- <Col span="24">
- <FormItem label="是否开启:">
- <i-switch
- v-model="formValidate.is_show"
- :true-value="1"
- :false-value="0"
- size="large"
- >
- <span slot="open">开启</span>
- <span slot="close">关闭</span>
- </i-switch>
- </FormItem>
- </Col>
- </Row>
- </Form>
- </Card>
- <Card
- :bordered="false"
- dis-hover
- class="fixed-card"
- :style="{ left: `${!menuCollapse ? '200px' : isMobile ? '0' : '80px'}` }"
- >
- <Form>
- <FormItem>
- <Button
- type="primary"
- class="submission"
- @click="handleSubmit('formValidate')"
- >保存</Button
- >
- </FormItem>
- </Form>
- </Card>
- </div>
- </template>
- <script>
- import { mapState, mapMutations } from 'vuex'
- import { getSupplier, addSupplier, putSupplier } from '@/api/supplier'
- import { cityApi } from '@/api/store'
- import Setting from "@/setting";
- export default {
- name: '',
- components: {},
- props: {},
- data() {
- return {
- roterPre: Setting.roterPre,
- width: 150,
- addresData: [],
- formValidate: {
- supplier_name: '',
- name: '',
- phone: '',
- detailed_address: '',
- address: '',
- addressSelect: [],
- email: '',
- mark: '',
- account: '',
- pwd: '',
- conf_pwd: '',
- is_show: 0,
- province: 0,
- city: 0,
- area: 0,
- street: 0,
- },
- ruleValidate: {
- supplier_name: [
- {
- required: true,
- message: '供应商不能为空',
- trigger: 'blur',
- },
- ],
- phone: [
- { required: true, message: '联系电话不能为空', trigger: 'blur' },
- {
- pattern: /^1[3456789]\d{9}$/,
- message: '手机号码格式不正确',
- trigger: 'blur',
- },
- ],
- account: [
- {
- required: true,
- message: '请输入用户名',
- trigger: 'blur',
- },
- ],
- address: [
- {
- required: true,
- message: '请填写具体地址',
- trigger: 'blur',
- },
- ],
- addressSelect: [
- {
- required: true,
- message: '请选择省市区',
- trigger: 'blur',
- },
- ],
- pwd: [
- {
- required: true,
- message: '请输入密码',
- trigger: 'blur',
- },
- ],
- conf_pwd: [
- {
- required: true,
- message: '密码不能为空',
- trigger: 'blur',
- },
- ],
- },
- }
- },
- computed: {
- ...mapState('admin/layout', ['isMobile', 'menuCollapse']),
- labelPosition() {
- return this.isMobile ? 'top' : 'right'
- },
- },
- watch: {},
- created() {
- let data = { pid: 0 }
- this.cityInfo(data)
- if (this.$route.params.id) {
- this.getSupplier()
- }
- },
- mounted() {},
- methods: {
- // 获取省市区
- cityInfo(data) {
- cityApi(data).then((res) => {
- this.addresData = res.data
- })
- },
- loadData(item, callback) {
- item.loading = true
- cityApi({ pid: item.value }).then((res) => {
- item.children = res.data
- item.loading = false
- callback()
- })
- },
- // 选择省市区
- addchack(e, selectedData) {
- e.forEach((i, index) => {
- if (index == 0) {
- this.formValidate.province = i
- } else if (index == 1) {
- this.formValidate.city = i
- } else if (index == 2) {
- this.formValidate.area = i
- } else {
- this.formValidate.street = i
- }
- })
- (this.formValidate.addressSelect)
- this.formValidate.address = selectedData.map((o) => o.label).join('')
- },
- // 添加供应商
- handleSubmit() {
- if (this.$route.params.id) {
- putSupplier(this.$route.params.id,this.formValidate)
- .then(async (res) => {
- this.$Message.success(res.msg)
- this.$router.push({ path: this.roterPre + '/supplier/menu/list' })
- })
- .catch((res) => {
- this.$Message.error(res.msg)
- })
- } else {
- addSupplier(this.formValidate)
- .then(async (res) => {
- this.$Message.success(res.msg)
- this.$router.push({ path: this.roterPre + '/supplier/menu/list' })
- })
- .catch((res) => {
- this.$Message.error(res.msg)
-
- })
- }
- },
- // 获取供应商信息
- getSupplier() {
- getSupplier(this.$route.params.id)
- .then(async (res) => {
- this.formValidate = res.data
- let addressSelect = []
- if (res.data.province) {
- addressSelect.push(res.data.province)
- }
- if (res.data.city) {
- addressSelect.push(res.data.city)
- }
- if (res.data.area) {
- addressSelect.push(res.data.area)
- }
- if (res.data.street) {
- addressSelect.push(res.data.street)
- }
- this.formValidate.addressSelect = addressSelect
- })
- .catch((res) => {
- this.$Message.error(res.msg)
- })
- },
- },
- }
- </script>
- <style scoped lang="less">
- .fixed-card {
- position: fixed;
- right: 0;
- bottom: 0;
- left: 200px;
- z-index: 99;
- box-shadow: 0 -1px 2px rgb(240, 240, 240);
- }
- .submission {
- margin-left: 50%;
- }
- </style>
|