Commit b82784da by weijiguang

test

parent 5b86185c
import { import {
login, login,
listCompany, listCompany,
myCompany,
createCompany, createCompany,
updateCompanyStatus, updateCompanyStatus,
updateCompanyExpired, updateCompanyExpired,
updateCompany, updateCompany,
listAccount,
listAccountMine,
createAccount,
updatePassword,
updateAccountStatus,
listSource,
createSource,
updateSource,
updateSourceStatus,
listModel,
listBrand,
createData,
} from "./request_methods"; } from "./request_methods";
export default { export default {
...@@ -17,6 +30,9 @@ export default { ...@@ -17,6 +30,9 @@ export default {
asyncListCompany(_, payload) { asyncListCompany(_, payload) {
return listCompany(payload) return listCompany(payload)
}, },
asyncMyCompany(_, payload) {
return myCompany(payload)
},
asyncCreateCompany(_, payload) { asyncCreateCompany(_, payload) {
return createCompany(payload) return createCompany(payload)
}, },
...@@ -29,6 +45,43 @@ export default { ...@@ -29,6 +45,43 @@ export default {
asyncUpdateCompany(_, payload) { asyncUpdateCompany(_, payload) {
return updateCompany(payload) return updateCompany(payload)
}, },
asyncListAccount(_, payload) {
return listAccount(payload)
},
asyncListAccountMine(_, payload) {
return listAccountMine(payload)
},
asyncCreateAccount(_, payload) {
return createAccount(payload)
},
asyncUpdatePassword(_, payload) {
return updatePassword(payload)
},
asyncUpdateAccountStatus(_, payload) {
return updateAccountStatus(payload)
},
asyncListSource(_, payload) {
return listSource(payload)
},
asyncCreateSource(_, payload) {
return createSource(payload)
},
asyncUpdateSource(_, payload) {
return updateSource(payload)
},
asyncUpdateSourceStatus(_, payload) {
return updateSourceStatus(payload)
},
asyncListModel(_, payload) {
return listModel(payload)
},
asyncListBrand(_, payload) {
return listBrand(payload)
},
asyncCreateData(_, payload) {
return createData(payload)
},
}, },
mutations: { mutations: {
} }
......
...@@ -11,6 +11,8 @@ export const login = data => axios.post(`${proxy}/account/login`, data); ...@@ -11,6 +11,8 @@ export const login = data => axios.post(`${proxy}/account/login`, data);
// 企业列表 // 企业列表
export const listCompany = data => axios.post(`${proxy}/company/list`, data); export const listCompany = data => axios.post(`${proxy}/company/list`, data);
// 企业信息
export const myCompany = data => axios.post(`${proxy}/company/mine`, data);
// 创建企业 // 创建企业
export const createCompany = data => axios.post(`${proxy}/company/create`, data); export const createCompany = data => axios.post(`${proxy}/company/create`, data);
// 企业状态 // 企业状态
...@@ -18,4 +20,31 @@ export const updateCompanyStatus = data => axios.post(`${proxy}/company/update/s ...@@ -18,4 +20,31 @@ export const updateCompanyStatus = data => axios.post(`${proxy}/company/update/s
// 企业有效期 // 企业有效期
export const updateCompanyExpired = data => axios.post(`${proxy}/company/update/expired`, data); export const updateCompanyExpired = data => axios.post(`${proxy}/company/update/expired`, data);
// 修改企业信息 // 修改企业信息
export const updateCompany = data => axios.post(`${proxy}/company/update`, data); export const updateCompany = data => axios.post(`${proxy}/company/update`, data);
\ No newline at end of file
// 帐号列表
export const listAccount = data => axios.post(`${proxy}/account/list/${data}`);
// 帐号列表
export const listAccountMine = data => axios.post(`${proxy}/account/list/mine`);
// 创建帐号
export const createAccount = data => axios.post(`${proxy}/account/create`, data);
// 修改帐号密码
export const updatePassword = data => axios.post(`${proxy}/account/update/password`, data);
// 修改帐号状态
export const updateAccountStatus = data => axios.post(`${proxy}/account/update/status`, data);
// 车源列表
export const listSource = data => axios.post(`${proxy}/data/sources`, data);
// 添加车源信息
export const createSource = data => axios.post(`${proxy}/data/source/create`, data);
// 修改车源停牌
export const updateSource = data => axios.post(`${proxy}/data/source/update`, data);
// 修改车源状态
export const updateSourceStatus = data => axios.post(`${proxy}/data/source/update/status`, data);
// 数据 / 型号列表
export const listModel = data => axios.post(`${proxy}/data/models`, data);
// 数据 / 品牌列表
export const listBrand = data => axios.post(`${proxy}/data/brands`, data);
// 数据 / 创建
export const createData = data => axios.post(`${proxy}/data/create`, data);
\ No newline at end of file
...@@ -81,18 +81,10 @@ export default [ ...@@ -81,18 +81,10 @@ export default [
component: () => import("@/view/data/source/index.vue") component: () => import("@/view/data/source/index.vue")
}, },
{ {
path: '/data/brand',
key: 'brand',
icon: 'logo-xbox',
title: '车辆品牌',
visable: false,
component: () => import("@/view/data/brand/index.vue")
},
{
path: '/data/model', path: '/data/model',
key: 'model', key: 'model',
icon: 'logo-xbox', icon: 'logo-xbox',
title: '车辆型号', title: '品牌型号',
visable: false, visable: false,
component: () => import("@/view/data/model/index.vue") component: () => import("@/view/data/model/index.vue")
} }
......
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
visible: false,
submitLoading: false,
accountFormRule: {
username: [
{
required: true,
message: "请输入帐号",
trigger: "blur"
}
],
password: [
{
required: true,
message: "请输入密码",
trigger: "blur"
}
],
realName: [
{
required: true,
message: "请输入真实姓名",
trigger: "blur"
}
],
phone: [
{
required: true,
message: "请输入联系电话",
trigger: "blur"
}
],
},
accountForm: {
username: "",
password: "",
realName: "",
phone: "",
address: "",
type: 0,
companyId: 0,
}
};
},
computed: {
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.accountForm.resetFields();
},
},
methods: {
saveAccount() {
this.$refs.accountForm.validate(valid => {
if (valid) {
this.submitLoading = true;
var tokenInfo = JSON.parse(localStorage.getItem("tokenInfo"));
if(tokenInfo.type != 0) {
this.accountForm.type = 2;
}
this.accountForm.companyId = tokenInfo.companyId;
dispatch("invoke/asyncCreateAccount", this.accountForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("添加成功");
this.$emit("search");
this.visible = false;
}
});
}
});
}
},
mounted() {
}
};
<template>
<div>
<Button icon="ios-add" type="primary" @click="visible = true">添加帐号</Button>
<Modal width="400" v-model="visible" title="帐号信息">
<div>
<Form ref="accountForm" :model="accountForm" :rules="accountFormRule" :label-width="60">
<Row>
<Col span="24">
<FormItem label="帐号:" prop="username">
<Input v-model.trim="accountForm.username" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="密码:" prop="password">
<Input v-model.trim="accountForm.password" type="password" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="姓名:" prop="realName">
<Input v-model.trim="accountForm.realName" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="电话:" prop="phone">
<Input v-model.trim="accountForm.phone" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="地址:" prop="address">
<Input v-model.trim="accountForm.address" type="text" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveAccount" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
export const columns = (disable, enable, updatePassword) => [
{
title: "帐号",
key: "username",
align: "center",
minWidth: 60,
},
{
title: "姓名",
key: "realName",
align: "center",
minWidth: 60,
},
{
title: "电话",
key: "phone",
align: "center",
minWidth: 60,
},
{
title: "地址",
key: "address",
align: "center",
minWidth: 60,
},
{
title: "类型",
align: "center",
width: 120,
render(h, { row }) {
try {
const { type } = row;
return h("span", type == 1 ? '主帐号' : '子帐号');
} catch(e) {
console.log(e);
}
}
},
{
title: "状态",
align: "center",
width: 120,
render(h, { row }) {
try {
const { status } = row;
return h("span", {style: {color: status == 1 ? 'green' : 'red' }}, status == 1 ? '有效' : '失效');
} catch(e) {
console.log(e);
}
}
},
{
title: "操作",
align: "center",
fixed: 'right',
width: 180,
render(h, { row }) {
const { status } = row;
var emptyTag = h("span"," ");
var updatePasswordTag = h(
"Button",
{
props: { type: "primary", size: "small" },
on: { click: () => {
updatePassword.dataSource = row;
updatePassword.visible = true;
}}
},
"修改密码"
);
var disableTag = h(
"Poptip",
{
props: { title: "确定停用当前帐号吗?", transfer: true, confirm: true, size: "small" },
on: { "on-ok": () => { row.status=0; disable(row); } }
},
[
h("Button", {props: {type: "error", size: "small"}}, "停用")
]
);
var enableTag = h(
"Button",
{
props: { type: "primary", size: "small" },
on: { click: () => { row.status=1; enable(row); }}
},
"启用"
);
return h("span", [updatePasswordTag, emptyTag, status == 1 ? disableTag : enableTag]);
}
},
];
import store from "@/store";
const { dispatch } = store;
import { columns } from "./helper.js";
import AddAccount from "./add/index.vue";
import UpdatePassword from "./updatePassword/index.vue";
export default {
components: { AddAccount, UpdatePassword },
data() {
return {
loading: false,
columns: [],
name: "",
data: {
records:[],
},
}
},
methods: {
disable(account) {
dispatch("invoke/asyncUpdateAccountStatus", account);
},
enable(account) {
dispatch("invoke/asyncUpdateAccountStatus", account);
},
search() {
this.loading = true;
dispatch("invoke/asyncListAccountMine", {}).then(({ data }) => {
this.loading = false
if (data != null) {
this.data.records = data;
} else {
this.data = {
records:[],
};
}
// console.log(this.data)
});
},
},
mounted() {
this.columns = columns(this.disable, this.enable, this.$refs.updatePassword);
this.search();
}
};
<template> <template>
<div> <div>
accounts <Card>
<AddAccount @search="search"/>
<UpdatePassword ref="updatePassword"/>
</Card>
<Card style="margin-top:10px">
<Table
border
:loading="loading"
:columns="columns"
:data="data.records"/>
</Card>
</div> </div>
</template> </template>
<script src="./index.js"></script>
<style>
.ivu-table-cell {
padding-left: 0;
padding-right: 0;
}
.ivu-table td {
height: 30px;
}
</style>
\ No newline at end of file
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
dataSource: null,
visible: false,
submitLoading: false,
accountFormRule: {
password: [
{
required: true,
message: "请输入密码",
trigger: "blur"
}
],
},
accountForm: {
id: 0,
username: "",
password: "",
}
};
},
computed: {
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.accountForm.resetFields();
this.accountForm.id = this.dataSource.id;
this.accountForm.username = this.dataSource.username;
},
},
methods: {
saveAccount() {
this.$refs.accountForm.validate(valid => {
if (valid) {
this.submitLoading = true;
dispatch("invoke/asyncUpdatePassword", this.accountForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("修改成功");
this.$emit("search");
this.visible = false;
}
});
}
});
},
},
mounted() {
}
};
<template>
<div>
<Modal width="400" v-model="visible" title="修改密码">
<div>
<Form ref="accountForm" :model="accountForm" :rules="accountFormRule" :label-width="60">
<Row>
<Col span="24">
<FormItem label="帐号:" prop="username">
<Input v-model.trim="accountForm.username" type="text" :disabled="true" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="密码:" prop="password">
<Input v-model.trim="accountForm.password" type="password" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveAccount" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
import EditCompany from "./add/index.vue";
import EditExpired from "./expired/index.vue";
export const columns = (search, disable, enable, updateExpired, updateCompany) => [
{
title: "企业名称",
key: "name",
align: "center",
minWidth: 60,
render: (h, { row }) => {
return h(EditCompany, {
props: { dataSource: row },
on: { search }
});
}
},
{
title: "企业简称",
key: "abbr",
align: "center",
minWidth: 60,
},
{
title: "地址",
key: "address",
align: "center",
minWidth: 60,
},
{
title: "联系人",
key: "contactName",
align: "center",
minWidth: 60,
},
{
title: "联系电话",
key: "contactPhone",
align: "center",
minWidth: 60,
},
{
title: "有效期",
key: "expiredDate",
align: "center",
minWidth: 60,
},
{
title: "省",
key: "province",
align: "center",
minWidth: 60,
},
{
title: "市",
key: "city",
align: "center",
minWidth: 60,
},
{
title: "区",
key: "district",
align: "center",
minWidth: 60,
},
{
title: "状态",
align: "center",
minWidth: 60,
render(h, { row }) {
try {
const { status } = row;
return h("span", {style: {color: status == 1 ? 'green' : 'red' }}, status == 1 ? '有效' : '失效');
} catch(e) {
console.log(e);
}
}
},
{
title: "操作",
align: "center",
fixed: 'right',
width: 180,
render(h, { row }) {
try {
const { status } = row;
var emptyTag = h("span"," ");
var disableTag = h(
"Poptip",
{
props: { title: "确定停用当前帐号吗?", transfer: true, confirm: true, size: "small" },
on: { "on-ok": () => { row.status=0; disable(row); } }
},
[
h("Button", {props: {type: "error", size: "small"}}, "停用")
]
);
var enableTag = h(
"Button",
{
props: { type: "primary", size: "small" },
on: { click: () => { row.status=1; enable(row); }}
},
"启用"
);
var updateExpiredTag = h(EditExpired, {
props: { dataSource: row },
on: { search }
});
return h("span", status == 1 ? [updateExpiredTag, emptyTag, disableTag] : [enableTag]);
} catch(e) {
console.log(e);
}
}
},
];
import store from "@/store";
const { dispatch } = store;
import { columns } from "./helper.js";
import EditCompany from "./add/index.vue";
export default {
components: { EditCompany },
data() {
return {
loading: false,
columns: [],
name: "",
changeCurrent: 1,
data: {
total:0,
current: 1,
records:[],
},
page: {
size: 10,
},
}
},
methods: {
disable(company) {
dispatch("invoke/asyncUpdateCompanyStatus", company);
},
enable(company) {
dispatch("invoke/asyncUpdateCompanyStatus", company);
},
updateExpired(company) {
dispatch("invoke/asyncUpdateCompanyExpired", company);
},
updateCompany(company) {
dispatch("invoke/asyncUpdateCompany", company);
},
search(current = 1) {
this.searchForm = {
name: this.name
};
this.loading = true
const initQuery = {
current,
size: this.page.size,
records: this.searchForm
};
dispatch("invoke/asyncListCompany", {
...initQuery
}).then(({ data }) => {
this.loading = false
if (data != null) {
this.data = {...data};
} else {
this.data = {
total:0,
current: 1,
records:[],
};
}
// console.log(this.data)
});
},
changePage(current) {
this.search(current);
this.changeCurrent = current
},
changeSize(value) {
this.page.size = value
this.search();
},
},
mounted() {
this.columns = columns(this.search, this.disable, this.enable, this.updateExpired, this.updateCompany);
this.search();
}
};
<template>
<div>
<Card>
<Form :label-width="100">
<Row>
<Col span="24">
企业名称:
<Input v-model="name" placeholder="Enter something..." style="width: 200px; margin-right:10px" />
<Button @click="() => search()" type="primary"><Icon type="ios-search-outline" /> 查询</Button>
<EditCompany class="searchBtn" @search="search" style="float:right" />
</Col>
</Row>
</Form>
</Card>
<Card style="margin-top:10px">
<Table
border
:loading="loading"
:columns="columns"
:data="data.records"/>
<Page
style="margin-top:10px"
:total="Number(data.total)"
:current="Number(data.current)"
@on-change="changePage"
@on-page-size-change="changeSize"
:placement="'top'"
:page-size-opts="[10, 30, 50, 100]"
show-sizer
show-elevator
show-total></Page>
</Card>
</div>
</template>
<script src="./index.js"></script>
<style>
.newTableClass {
overflow: visible;
}
.ivu-table-cell {
padding-left: 0;
padding-right: 0;
}
.ivu-table td {
height: 30px;
}
</style>
\ No newline at end of file
...@@ -27,14 +27,14 @@ export default { ...@@ -27,14 +27,14 @@ export default {
trigger: "blur" trigger: "blur"
} }
], ],
contectName: [ contactName: [
{ {
required: true, required: true,
message: "请输入联系人", message: "请输入联系人",
trigger: "blur" trigger: "blur"
} }
], ],
contectPhone: [ contactPhone: [
{ {
required: true, required: true,
message: "请输入联系电话", message: "请输入联系电话",
...@@ -55,8 +55,8 @@ export default { ...@@ -55,8 +55,8 @@ export default {
name: "", name: "",
abbr: "", abbr: "",
address: "", address: "",
contectName: "", contactName: "",
contectPhone: "", contactPhone: "",
expiredDate: "" expiredDate: ""
} }
}; };
...@@ -75,8 +75,8 @@ export default { ...@@ -75,8 +75,8 @@ export default {
this.companyForm.name = this.dataSource.name; this.companyForm.name = this.dataSource.name;
this.companyForm.abbr = this.dataSource.abbr; this.companyForm.abbr = this.dataSource.abbr;
this.companyForm.address = this.dataSource.address; this.companyForm.address = this.dataSource.address;
this.companyForm.contectName = this.dataSource.contectName; this.companyForm.contactName = this.dataSource.contactName;
this.companyForm.contectPhone = this.dataSource.contectPhone; this.companyForm.contactPhone = this.dataSource.contactPhone;
this.abbrDisabled = true; this.abbrDisabled = true;
} else { // 添加 } else { // 添加
...@@ -97,8 +97,8 @@ export default { ...@@ -97,8 +97,8 @@ export default {
name: this.companyForm.name, name: this.companyForm.name,
abbr: this.companyForm.abbr, abbr: this.companyForm.abbr,
address: this.companyForm.address, address: this.companyForm.address,
contectName: this.companyForm.contectName, contactName: this.companyForm.contactName,
contectPhone: this.companyForm.contectPhone, contactPhone: this.companyForm.contactPhone,
expiredDate: moment(this.companyForm.expiredDate).valueOf() expiredDate: moment(this.companyForm.expiredDate).valueOf()
} }
var methodName = this.dataSource ? "invoke/asyncUpdateCompany" : "invoke/asyncCreateCompany"; var methodName = this.dataSource ? "invoke/asyncUpdateCompany" : "invoke/asyncCreateCompany";
......
...@@ -28,15 +28,15 @@ ...@@ -28,15 +28,15 @@
</Row> </Row>
<Row> <Row>
<Col span="24" style="margin-top:-5px"> <Col span="24" style="margin-top:-5px">
<FormItem label="联系人:" prop="contectName"> <FormItem label="联系人:" prop="contactName">
<Input v-model.trim="companyForm.contectName" type="text" /> <Input v-model.trim="companyForm.contactName" type="text" />
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col span="24" style="margin-top:-5px"> <Col span="24" style="margin-top:-5px">
<FormItem label="联系电话:" prop="contectPhone"> <FormItem label="联系电话:" prop="contactPhone">
<Input v-model.trim="companyForm.contectPhone" type="text" /> <Input v-model.trim="companyForm.contactPhone" type="text" />
</FormItem> </FormItem>
</Col> </Col>
</Row> </Row>
......
...@@ -28,13 +28,13 @@ export const columns = (search, disable, enable, updateExpired, updateCompany) = ...@@ -28,13 +28,13 @@ export const columns = (search, disable, enable, updateExpired, updateCompany) =
}, },
{ {
title: "联系人", title: "联系人",
key: "contectName", key: "contactName",
align: "center", align: "center",
minWidth: 60, minWidth: 60,
}, },
{ {
title: "联系电话", title: "联系电话",
key: "contectPhone", key: "contactPhone",
align: "center", align: "center",
minWidth: 60, minWidth: 60,
}, },
...@@ -88,7 +88,7 @@ export const columns = (search, disable, enable, updateExpired, updateCompany) = ...@@ -88,7 +88,7 @@ export const columns = (search, disable, enable, updateExpired, updateCompany) =
var disableTag = h( var disableTag = h(
"Poptip", "Poptip",
{ {
props: { title: "确定停用当前帐号吗?", transfer: true, confirm: true, size: "small" }, props: { title: "确定停用当前企业吗?", transfer: true, confirm: true, size: "small" },
on: { "on-ok": () => { row.status=0; disable(row); } } on: { "on-ok": () => { row.status=0; disable(row); } }
}, },
[ [
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
企业名称: 企业名称:
<Input v-model="name" placeholder="Enter something..." style="width: 200px; margin-right:10px" /> <Input v-model="name" placeholder="Enter something..." style="width: 200px; margin-right:10px" />
<Button @click="() => search()" type="primary"><Icon type="ios-search-outline" /> 查询</Button> <Button @click="() => search()" type="primary"><Icon type="ios-search-outline" /> 查询</Button>
<EditCompany class="searchBtn" @search="search" style="float:right" /> <EditCompany @search="search" style="float:right" />
</Col> </Col>
</Row> </Row>
</Form> </Form>
...@@ -36,9 +36,6 @@ ...@@ -36,9 +36,6 @@
<script src="./index.js"></script> <script src="./index.js"></script>
<style> <style>
.newTableClass {
overflow: visible;
}
.ivu-table-cell { .ivu-table-cell {
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
......
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
loading: false,
company: null,
}
},
methods: {
getMyCompany() {
this.loading = true
dispatch("invoke/asyncMyCompany").then(({ data }) => {
this.loading = false
if (data != null) {
this.company = {...data};
} else {
this.company = null;
}
// console.log(this.data)
});
},
},
mounted() {
this.getMyCompany();
}
};
<template> <template>
<div> <div>
info <Card>
<Form :label-width="100" :label-colon="true" id="fontstyle">
<Row>
<Col span="24">
<FormItem label="企业ID">{{ company.id }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="企业名称">{{ company.name }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="企业简称">{{ company.abbr }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="企业地址">{{ company.address }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系人">{{ company.contactName }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系电话">{{ company.contactPhone }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="省/市/区">{{ company.province }} / {{ company.city }} / {{ company.district }}</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="状态">{{ company.status == 1 ? "正常" : "禁用" }}</FormItem>
</Col>
</Row>
</Form>
</Card>
</div> </div>
</template> </template>
<script src="./index.js"></script>
<style>
.ivu-table-cell {
padding-left: 0;
padding-right: 0;
}
.ivu-table td {
height: 30px;
}
#fontstyle .ivu-form-item-label {
font-weight:bold;
}
#fontstyle .ivu-form-item-content {
color:#999;
}
</style>
\ No newline at end of file
<template>
<div>
brand
</div>
</template>
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
visible: false,
submitLoading: false,
dataFormRule: {
code: [
{
required: true,
message: "请输入品牌编码",
trigger: "blur"
}
],
name: [
{
required: true,
message: "请输入品牌名称",
trigger: "blur"
}
],
},
dataForm: {
code: "",
name: "",
type: 6,
}
};
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.dataForm.resetFields();
},
},
methods: {
saveData() {
this.$refs.dataForm.validate(valid => {
if (valid) {
this.submitLoading = true;
dispatch("invoke/asyncCreateData", this.dataForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("添加成功");
this.$emit("getBrands");
this.visible = false;
}
});
}
});
}
},
};
<template>
<div>
<!-- <Button icon="ios-add" type="primary" @click="visible = true">添加品牌</Button> -->
<Modal width="400" v-model="visible" title="品牌信息">
<div>
<Form ref="dataForm" :model="dataForm" :rules="dataFormRule" :label-width="100">
<Row>
<Col span="24">
<FormItem label="品牌编码" prop="code">
<Input v-model.trim="dataForm.code" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="品牌名称" prop="name">
<Input v-model.trim="dataForm.name" type="text" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveData" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
brands: null,
visible: false,
submitLoading: false,
dataFormRule: {
parentId: [
{
type:"number",
required: true,
message: "请选择品牌",
trigger: "blur"
}
],
code: [
{
required: true,
message: "请输入型号编码",
trigger: "blur"
}
],
name: [
{
required: true,
message: "请输入型号名称",
trigger: "blur"
}
],
},
dataForm: {
parentId: null,
code: "",
name: "",
type: 7,
}
};
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.dataForm.resetFields();
},
},
methods: {
saveData() {
this.$refs.dataForm.validate(valid => {
if (valid) {
this.submitLoading = true;
dispatch("invoke/asyncCreateData", this.dataForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("添加成功");
this.$emit("search");
this.visible = false;
}
});
}
});
},
},
};
<template>
<div>
<Modal width="400" v-model="visible" title="型号信息">
<div>
<Form ref="dataForm" :model="dataForm" :rules="dataFormRule" :label-width="100">
<Row>
<Col span="24">
<FormItem label="品牌" prop="parentId">
<Select v-model="dataForm.parentId" clearable>
<Option v-for="item in brands" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select>
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="型号编码" prop="code">
<Input v-model.trim="dataForm.code" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="型号名称" prop="name">
<Input v-model.trim="dataForm.name" type="text" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveData" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
export const columns = (disable, enable, updatePassword) => [
{
title: "品牌ID",
key: "brandId",
align: "center",
minWidth: 60,
},
{
title: "品牌",
key: "brandName",
align: "center",
minWidth: 60,
},
{
title: "型号ID",
key: "id",
align: "center",
minWidth: 60,
},
{
title: "型号",
key: "name",
align: "center",
minWidth: 60,
},
{
title: "扩展字段",
key: "extends",
align: "center",
minWidth: 60,
},
];
import store from "@/store";
const { dispatch } = store;
import { columns } from "./helper.js";
import AddBrand from "./addBrand/index.vue";
import AddModel from "./addModel/index.vue";
export default {
components: { AddBrand, AddModel },
data() {
return {
loading: false,
columns: [],
parentId: null,
changeCurrent: 1,
data: [],
brands: [],
}
},
methods: {
showAddBrand() {
this.$refs.addBrandDialog.visible = true;
},
showAddModel() {
this.$refs.addModelDialog.visible = true;
this.$refs.addModelDialog.brands = this.brands;
},
search() {
var searchForm = {
parentId: this.parentId
};
dispatch("invoke/asyncListModel", searchForm).then(({ data }) => {
this.loading = false;
if (data != null) {
this.data = data;
} else {
this.data = [];
}
});
},
getBrands() {
dispatch("invoke/asyncListBrand").then(({ data }) => {
this.loading = false;
this.brands = data;
});
},
},
mounted() {
this.getBrands();
this.columns = columns(this.disable, this.enable, this.$refs.editDialog);
this.search();
}
};
<template> <template>
<div> <div>
model <Card>
<Form :label-width="100">
<Row>
<Col span="12">
品牌名称:
<Select v-model="parentId" style="width:200px" clearable>
<Option v-for="item in brands" :value="item.id" :key="item.id">{{ item.name }}</Option>
</Select> &nbsp;
<Button @click="() => search()" type="primary"><Icon type="ios-search-outline" /> 查询</Button>
</Col>
<Col span="12">
<div style="float:right">
<Button icon="ios-add" type="primary" @click="showAddBrand">添加品牌</Button> &nbsp;
<Button icon="ios-add" type="primary" @click="showAddModel">添加型号</Button>
<AddBrand @getBrands="getBrands" ref="addBrandDialog" />
<AddModel @search="search" ref="addModelDialog" />
</div>
</Col>
</Row>
</Form>
</Card>
<Card style="margin-top:10px">
<Table
border
:loading="loading"
:columns="columns"
:data="data" />
</Card>
</div> </div>
</template> </template>
<script src="./index.js"></script>
<style>
.ivu-table-cell {
padding-left: 0;
padding-right: 0;
}
.ivu-table td {
height: 30px;
}
</style>
\ No newline at end of file
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
visible: false,
submitLoading: false,
sourceFormRule: {
name: [
{
required: true,
message: "请输入车源名称",
trigger: "blur"
}
],
},
sourceForm: {
name: "",
contactName: "",
contactPhone: "",
address: "",
}
};
},
computed: {
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.sourceForm.resetFields();
},
},
methods: {
saveSource() {
this.$refs.sourceForm.validate(valid => {
if (valid) {
this.submitLoading = true;
dispatch("invoke/asyncCreateSource", this.sourceForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("添加成功");
this.$emit("search");
this.visible = false;
}
});
}
});
}
},
mounted() {
}
};
<template>
<div>
<Button icon="ios-add" type="primary" @click="visible = true">添加车源</Button>
<Modal width="400" v-model="visible" title="车源信息">
<div>
<Form ref="sourceForm" :model="sourceForm" :rules="sourceFormRule" :label-width="100">
<Row>
<Col span="24">
<FormItem label="车源名称:" prop="name">
<Input v-model.trim="sourceForm.name" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系人:" prop="contactName">
<Input v-model.trim="sourceForm.contactName" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系电话:" prop="contactPhone">
<Input v-model.trim="sourceForm.contactPhone" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系地址:" prop="address">
<Input v-model.trim="sourceForm.address" type="password" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveSource" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
import store from "@/store";
const { dispatch } = store;
export default {
components: { },
data() {
return {
dataSource: null,
visible: false,
submitLoading: false,
sourceFormRule: {
name: [
{
required: true,
message: "请输入车源名称",
trigger: "blur"
}
],
},
sourceForm: {
id: 0,
name: "",
contactName: "",
contactPhone: "",
address: "",
}
};
},
computed: {
},
watch: {
visible(show) {
this.submitLoading = false;
this.$refs.sourceForm.resetFields();
this.sourceForm.id = this.dataSource.id;
this.sourceForm.name = this.dataSource.name;
this.sourceForm.contactName = this.dataSource.contactName;
this.sourceForm.contactPhone = this.dataSource.contactPhone;
this.sourceForm.address = this.dataSource.address;
},
},
methods: {
saveSource() {
this.$refs.sourceForm.validate(valid => {
if (valid) {
this.submitLoading = true;
dispatch("invoke/asyncUpdateSource", this.sourceForm).then(({ code }) => {
this.submitLoading = false;
if (code === 1) {
this.$Message.success("修改成功");
this.$emit("search");
this.visible = false;
}
});
}
});
}
},
mounted() {
}
};
<template>
<div>
<!-- <Button icon="ios-add" type="primary" @click="visible = true">添加车源</Button> -->
<Modal width="400" v-model="visible" title="车源信息">
<div>
<Form ref="sourceForm" :model="sourceForm" :rules="sourceFormRule" :label-width="100">
<Row>
<Col span="24">
<FormItem label="车源名称:" prop="name">
<Input v-model.trim="sourceForm.name" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系人:" prop="contactName">
<Input v-model.trim="sourceForm.contactName" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系电话:" prop="contactPhone">
<Input v-model.trim="sourceForm.contactPhone" type="text" />
</FormItem>
</Col>
</Row>
<Row>
<Col span="24">
<FormItem label="联系地址:" prop="address">
<Input v-model.trim="sourceForm.address" type="text" />
</FormItem>
</Col>
</Row>
</Form>
</div>
<div slot="footer">
<Button @click="visible = false">取消</Button>
<Button @click="saveSource" :loading="submitLoading" type="primary">确定</Button>
</div>
</Modal>
</div>
</template>
<script src="./index.js"/>
export const columns = (disable, enable, editDialog) => [
{
title: "车源名称",
align: "center",
minWidth: 60,
render: (h, { row }) => {
const { name } = row;
return h(
"a",
{
on: { click: () => {
editDialog.dataSource = row;
editDialog.visible = true;
}}
},
name
);
}
},
{
title: "联系人",
key: "contactName",
align: "center",
minWidth: 60,
},
{
title: "联系电话",
key: "contactPhone",
align: "center",
minWidth: 60,
},
{
title: "地址",
key: "address",
align: "center",
minWidth: 60,
},
{
title: "状态",
align: "center",
minWidth: 60,
render(h, { row }) {
try {
const { status } = row;
return h("span", {style: {color: status == 1 ? 'green' : 'red' }}, status == 1 ? '有效' : '失效');
} catch(e) {
console.log(e);
}
}
},
{
title: "操作",
align: "center",
fixed: 'right',
width: 180,
render(h, { row }) {
try {
const { status } = row;
var disableTag = h(
"Poptip",
{
props: { title: "确定停用当前车源吗?", transfer: true, confirm: true, size: "small" },
on: { "on-ok": () => { disable(row); } }
},
[
h("Button", {props: {type: "error", size: "small"}}, "停用")
]
);
var enableTag = h(
"Button",
{
props: { type: "primary", size: "small" },
on: { click: () => { enable(row); }}
},
"启用"
);
return h("span", status == 1 ? [disableTag] : [enableTag]);
} catch(e) {
console.log(e);
}
}
},
];
import store from "@/store";
const { dispatch } = store;
import { columns } from "./helper.js";
import AddSource from "./add/index.vue";
import EditSource from "./edit/index.vue";
export default {
components: { AddSource, EditSource },
data() {
return {
loading: false,
columns: [],
name: "",
changeCurrent: 1,
data: [],
}
},
methods: {
disable(source) {
var requestData = { id : source.id, status : 0 }
dispatch("invoke/asyncUpdateSourceStatus", requestData).then(({ data }) => {
source.status = 0;
});
},
enable(source) {
var requestData = { id : source.id, status : 1 }
dispatch("invoke/asyncUpdateSourceStatus", requestData).then(({ data }) => {
source.status = 1;
});
},
search() {
var searchForm = {
name: this.name
};
dispatch("invoke/asyncListSource", searchForm).then(({ data }) => {
this.loading = false;
if (data != null) {
this.data = data;
} else {
this.data = [];
}
});
},
},
mounted() {
this.columns = columns(this.disable, this.enable, this.$refs.editDialog);
this.search();
}
};
<template> <template>
<div> <div>
source <Card>
<Form :label-width="100">
<Row>
<Col span="12">
车源名称:
<Input v-model="name" placeholder="Enter something..." style="width: 200px; margin-right:10px" />
<Button @click="() => search()" type="primary"><Icon type="ios-search-outline" /> 查询</Button>
</Col>
<Col span="12">
<AddSource @search="search" ref="addDialog" style="float:right"/>
<EditSource @search="search" ref="editDialog"/>
</Col>
</Row>
</Form>
</Card>
<Card style="margin-top:10px">
<Table
border
:loading="loading"
:columns="columns"
:data="data" />
</Card>
</div> </div>
</template> </template>
<script src="./index.js"></script>
<style>
.ivu-table-cell {
padding-left: 0;
padding-right: 0;
}
.ivu-table td {
height: 30px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment