前端首页
<template>
<div class="app-container">
<el-form ref="queryForm" :model="queryParams" :inline="true">
<el-form-item label="供应商名称" prop="mc">
<el-input v-model="queryParams.mc" placeholder="供应商名称"/>
el-form-item>
<el-form-item label="供应商类型" prop="lx">
<el-select v-model="queryParams.lx" placeholder="供应商类型">
<el-option v-for="item in lxOperations" :key="item.value" :label="item.label" :value="item.value">
el-option>
el-select>
el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置el-button>
el-form-item>
el-form>
<el-row>
<el-row :gutter="10">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['jcpz:gyspz:add']">新增el-button>
el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" @click="handleUpdate" :disabled="single" v-hasPermi="['jcpz:gyspz:edit']">修改el-button>
el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleDelete" :disabled="multiple" v-hasPermi="['jcpz:gyspz:remove']">删除el-button>
el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['jcpz:gyspz:export']">导出el-button>
el-col>
el-row>
el-row>
<el-table v-loading="loading" :data="dataList" row-key="bbm" :header-cell-style="{ background: '#eef1f6', color: '#606266', 'text-align': 'center' }" @selection-change="handleSelectionChange" style="width: 100%;margin-top:5px" :height="tableHeight">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" width="70px">
<template #default="scope">
<span>{{ (queryParams.pageNum - 1) * (queryParams.pageSize) + scope.$index + 1 }}span>
template>
el-table-column>
<el-table-column label="供应商名称" align="center" prop="mc" :show-overflow-tooltip="true" />
<el-table-column label="联系电话" align="center" prop="lxdh" :show-overflow-tooltip="true" />
<el-table-column label="地址" align="center" prop="dz" :show-overflow-tooltip="true" />
<el-table-column label="供应商类型" align="center" prop="lx" :show-overflow-tooltip="true">
<template slot-scope="scope">
<div v-if="scope.row.lx == '0'" style="color: #1c84c6">供应商div>
<div v-if="scope.row.lx == '1'" style="color: #0ba32f">销售对象div>
template>
el-table-column>
el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
<add-edit ref="addEdit" @success_="getList">add-edit>
div>
template>
<script>
import addEdit from './dataM.vue'
import { listType, infoType, delType } from '@/api/jcpz/gyspz'
export default {
name: 'Gyspz',
components: { addEdit },
data() {
return {
tableHeight:window.innerHeight - 300,
loading: false,
ids: [],
single: true,
multiple: true,
total: 0,
dateRange: [],
queryParams: { pageNum: 1, pageSize: 20, mc: null, lx: null },
dataList: [],
lxOperations: [{label: '供应商', value: '0'}, {label: '销售对象', value: '1'}],
}
},
mounted(){
this.getList()
},
methods: {
getList(){
this.loading = true;
listType(this.addDateRange(this.queryParams, this.dateRange)).then((res) => {
this.dataList = res.rows;
this.total = res.total;
this.loading = false;
})
},
handleAdd(){
this.$refs.addEdit.title = '添加供应商信息'
this.$refs.addEdit.lxOperations = this.lxOperations
this.$refs.addEdit.visible = true
},
handleUpdate(row){
const id = row.bbm || this.ids
infoType(id).then((res) => {
this.$refs.addEdit.title = '修改供应商信息'
this.$refs.addEdit.lxOperations = this.lxOperations
this.$refs.addEdit.form = res.data
this.$refs.addEdit.visible = true
})
},
handleDelete(row){
const ids = row.bbm || this.ids;
this.$modal.confirm('是否确认删除编号为"' + ids + '"的数据项?').then(function () {
return delType(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
},
handleExport(){
this.download('xxx/export', {
...this.queryParams
}, `gyspz_${new Date().getTime()}.xlsx`)
},
handleQuery(){
this.queryParams.pageNum = 1;
this.getList();
},
resetQuery(){
this.dateRange = [];
this.queryParams = { pageNum: 1, pageSize: 20, mc: null, lx: null }
this.resetForm("queryForm");
this.handleQuery();
},
handleSelectionChange(selection) {
this.ids = selection.map(item => item.bbm)
this.single = selection.length != 1
this.multiple = !selection.length
},
}
}
script>
前端弹框
<template>
<el-dialog :title="title" :visible.sync="visible" width="40%" :before-close="handleOnClose" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="供应商名称" prop="mc">
<el-input v-model="form.mc" placeholder="供应商名称"/>
el-form-item>
el-col>
<el-col :span="12">
<el-form-item label="类型" prop="lx">
<el-select v-model="form.lx" placeholder="供应商类型" style="width: 100%">
<el-option v-for="item in lxOperations" :key="item.value" :label="item.label" :value="item.value">
el-option>
el-select>
el-form-item>
el-col>
el-row>
<el-row>
<el-col :span="12">
<el-form-item label="联系电话" prop="lxdh">
<el-input v-model="form.lxdh" placeholder="联系电话"/>
el-form-item>
el-col>
<el-col :span="12">
<el-form-item label="地址" prop="dz">
<el-input v-model="form.dz" placeholder="地址"/>
el-form-item>
el-col>
el-row>
el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定el-button>
<el-button @click="handleOnClose">取 消el-button>
div>
el-dialog>
template>
<script>
import { updateType, addType } from '@/api/jcpz/gyspz'
export default {
name: 'GyspzDate',
data(){
return{
title: null,
visible: false,
form: {mc: null, lx: null, lxdh: null, dz: null},
rules: {
mc: [{ required: true, message: "名称不能为空", trigger: "blur" }],
lx: [{ required: true, message: "类型不能为空", trigger: "blur" }],
},
lxOperations: [],
}
},
methods:{
submitForm: function () {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.bbm != undefined) {
updateType(this.form).then((res) => {
this.$message.success('success')
this.handleOnClose()
this.$emit("success_")
})
} else {
addType(this.form).then((res) => {
this.$message.success('success')
this.handleOnClose()
this.$emit("success_")
})
}
}
})
},
handleOnClose() {
this.$refs["form"].resetFields();
this.form = {mc: null, lx: null, lxdh: null, dz: null};
this.visible = false
},
}
}
script>
JS文件
import request from '@/utils/request'
export function listType(query) {
return request({
url: '/xxx/xxx/list',
method: 'get',
params: query
})
}
export function infoType(id) {
return request({
url: '/xxx/xxx/' + id,
method: 'get'
})
}
export function addType(data) {
return request({
url: '/xxx/xxx',
method: 'post',
data: data
})
}
export function updateType(data) {
return request({
url: '/xxx/xxx/',
method: 'put',
data: data
})
}
export function delType(ids) {
return request({
url: '/xxx/xxx/' + ids,
method: 'delete'
})
}
export function dictType(lx) {
return request({
url: '/xxx/xxx/dict/' + lx,
method: 'get'
})
}