Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <script lang="ts" setup> |
| | | import { reactive, ref } from 'vue' |
| | | import type { FormInstance, FormRules } from 'element-plus' |
| | | import {onMounted, reactive, ref} from "vue"; |
| | | import {useRoute, useRouter} from "vue-router" |
| | | import request from "@/utils/request" |
| | | import {ElMessage} from "element-plus"; |
| | | import deepClone from "@/utils/deepClone" |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | | let produceList = ref([]) |
| | | |
| | | const ruleFormRef = ref<FormInstance>() |
| | | |
| | | const checkAge = (rule: any, value: any, callback: any) => { |
| | | if (!value) { |
| | | return callback(new Error('Please input the age')) |
| | | } |
| | | setTimeout(() => { |
| | | if (!Number.isInteger(value)) { |
| | | callback(new Error('Please input digits')) |
| | | } else { |
| | | if (value < 18) { |
| | | callback(new Error('Age must be greater than 18')) |
| | | } else { |
| | | callback() |
| | | |
| | | |
| | | let ruleForm = ref({ |
| | | id:0, |
| | | customerName: '', |
| | | grade: '', |
| | | moneyLimit: '', |
| | | address: '', |
| | | contact: '', |
| | | phone: '' |
| | | |
| | | }) |
| | | |
| | | |
| | | |
| | | onMounted(()=>{ |
| | | |
| | | //获取传过来的数据进行判断 |
| | | const str = route.query.id |
| | | if (typeof str != 'undefined' && str != null && str !== '' && str !== '\n' && str !== '\r'){ |
| | | ruleForm.value.id = Number(str) |
| | | |
| | | request.post(`/customer/getseletCustomer/1/100`,ruleForm.value).then((res) => { |
| | | if(res.code==200){ |
| | | console.log(res.data.data) |
| | | ruleForm.value=deepClone(res.data.data[0]) |
| | | |
| | | console.log(ruleForm.value) |
| | | |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | } |
| | | }, 1000) |
| | | } |
| | | |
| | | const validatePass = (rule: any, value: any, callback: any) => { |
| | | if (value === '') { |
| | | callback(new Error('Please input the password')) |
| | | } else { |
| | | if (ruleForm.checkPass !== '') { |
| | | if (!ruleFormRef.value) return |
| | | ruleFormRef.value.validateField('checkPass', () => null) |
| | | } |
| | | callback() |
| | | }) |
| | | } |
| | | } |
| | | const validatePass2 = (rule: any, value: any, callback: any) => { |
| | | if (value === '') { |
| | | callback(new Error('Please input the password again')) |
| | | } else if (value !== ruleForm.pass) { |
| | | callback(new Error("Two inputs don't match!")) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | |
| | | const ruleForm = reactive({ |
| | | pass: '', |
| | | checkPass: '', |
| | | age: '', |
| | | |
| | | }) |
| | | |
| | | const rules = reactive<FormRules<typeof ruleForm>>({ |
| | | pass: [{ validator: validatePass, trigger: 'blur' }], |
| | | checkPass: [{ validator: validatePass2, trigger: 'blur' }], |
| | | age: [{ validator: checkAge, trigger: 'blur' }], |
| | | }) |
| | | |
| | | const submitForm = (formEl: FormInstance | undefined) => { |
| | | if (!formEl) return |
| | | formEl.validate((valid) => { |
| | | if (valid) { |
| | | console.log('submit!') |
| | | } else { |
| | | console.log('error submit!') |
| | | return false |
| | | //保存提交 |
| | | const submitForm = () => { |
| | | //表头数据校验 |
| | | const customerName = ruleForm.value.customerName |
| | | if(customerName === null || customerName === undefined || customerName === ''){ |
| | | ElMessage.error('输入客户名称!') |
| | | return |
| | | } |
| | | const grade = ruleForm.value.grade |
| | | if(grade === null || grade === undefined || grade === ''){ |
| | | ElMessage.error('输入客户等级!') |
| | | return |
| | | } |
| | | const moneyLimit = ruleForm.value.moneyLimit |
| | | if(moneyLimit === null || moneyLimit === undefined || moneyLimit === ''){ |
| | | ElMessage.error('输入金额额度!') |
| | | return |
| | | } |
| | | const address = ruleForm.value.address |
| | | if(address === null || address === undefined || address === ''){ |
| | | ElMessage.error('输入联系地址!') |
| | | return |
| | | } |
| | | const contact = ruleForm.value.contact |
| | | if(contact === null || contact === undefined || contact === ''){ |
| | | ElMessage.error('输入联系人!') |
| | | return |
| | | } |
| | | const phone = ruleForm.value.phone |
| | | if(phone === null || phone === undefined || phone === ''){ |
| | | ElMessage.error('输入类型电话!') |
| | | return |
| | | } |
| | | |
| | | let flowData = ref({ |
| | | customer: ruleForm |
| | | }) |
| | | |
| | | console.log(flowData) |
| | | request.post("/customer/insertCustomer", flowData.value).then((res) => { |
| | | if(res.code==200){ |
| | | resetForm() |
| | | ElMessage.success("提交成功") |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | } |
| | | |
| | | const resetForm = (formEl: FormInstance | undefined) => { |
| | | if (!formEl) return |
| | | formEl.resetFields() |
| | | } |
| | | //重置输入框 |
| | | const resetForm = () => { |
| | | ruleForm.value.customerName="" |
| | | ruleForm.value.grade="" |
| | | ruleForm.value.moneyLimit="" |
| | | ruleForm.value.address="" |
| | | ruleForm.value.contact="" |
| | | ruleForm.value.phone="" |
| | | } |
| | | </script> |
| | | |
| | | <template> |
| | | <div class="main-div"> |
| | | <div class="div-form"> |
| | | <el-form |
| | | ref="ruleFormRef" |
| | | :model="ruleForm" |
| | | status-icon |
| | | :rules="rules" |
| | | label-width="120px" |
| | | class="demo-ruleForm" |
| | | > |
| | | <el-form-item label="客户名称" prop="pass"> |
| | | <el-input v-model="ruleForm.pass" type="text" autocomplete="off" /> |
| | | </el-form-item> |
| | | <el-form-item label="客户等级" prop="checkPass"> |
| | | <el-input |
| | | v-model="ruleForm.checkPass" |
| | | type="text" |
| | | autocomplete="off" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="信用额度" prop="age"> |
| | | <el-input v-model.number="ruleForm.age" /> |
| | | </el-form-item> |
| | | <el-form-item label="地址" prop="age"> |
| | | <el-input v-model.number="ruleForm.age" /> |
| | | </el-form-item> |
| | | <el-form-item label="联系人" prop="age"> |
| | | <el-input v-model.number="ruleForm.age" /> |
| | | </el-form-item> |
| | | <el-form-item label="联系电话" prop="age"> |
| | | <el-input v-model.number="ruleForm.age" /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="submitForm(ruleFormRef)" |
| | | >保存</el-button |
| | | > |
| | | <el-button @click="resetForm(ruleFormRef)">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | | <div class="order-primary" > |
| | | <el-row> |
| | | <el-col :span="1"><el-text>客户名称:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.customerName" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-text>客户等级:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.grade" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-text>信用额度:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.moneyLimit" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-text>地址:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.address" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-text>联系人:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.contact" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-text>联系电话:</el-text></el-col> |
| | | <el-col :span="5"><el-input style="font-size: large;color: #181818" v-model="ruleForm.phone" ></el-input></el-col> |
| | | </el-row> |
| | | <el-row> |
| | | <el-col :span="1"><el-button type="primary" @click="submitForm()">保存</el-button></el-col> |
| | | <el-col :span="1"><el-button @click="resetForm()">重置</el-button></el-col> |
| | | </el-row> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | |
| | |
| | | height:70%; |
| | | width: 40%; |
| | | } |
| | | .el-row{ |
| | | margin-bottom: 0.5rem; |
| | | } |
| | | </style> |
| | |
| | | <script setup> |
| | | |
| | | import {reactive} from "vue"; |
| | | import {reactive, ref} from "vue"; |
| | | import {useRouter} from 'vue-router' |
| | | import request from "@/utils/request" |
| | | import deepClone from "@/utils/deepClone" |
| | | import VXETable from "vxe-table"; |
| | | import useUserInfoStore from "@/stores/userInfo"; |
| | | import {ElMessage} from "element-plus"; |
| | | |
| | | const userStore = useUserInfoStore() |
| | | const username = userStore.user.userName |
| | | const userid = userStore.user.userId |
| | | let router=useRouter() |
| | | let produceList = ref([]) |
| | | const getTableRow = (row,type) =>{ |
| | | switch (type) { |
| | | case 'edit' :{ |
| | |
| | | break |
| | | } |
| | | case 'delete':{ |
| | | alert('我接收到子组件传送的删除信息') |
| | | let ruleForm = ref({ |
| | | id:0, |
| | | customerName: '', |
| | | grade: '', |
| | | moneyLimit: '', |
| | | address: '', |
| | | contact: '', |
| | | phone: '' |
| | | |
| | | }) |
| | | ruleForm.value.id=row.id |
| | | let flowData = ref({ |
| | | customer: ruleForm.value |
| | | }) |
| | | |
| | | request.post("/customer/deleteCustomer", flowData.value).then((res) => { |
| | | if(res.code==200){ |
| | | ElMessage.success("删除成功") |
| | | location.reload(); |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | break |
| | | } |
| | | } |
| | | } |
| | | |
| | | const hasDecimal=(value)=>{ |
| | | const regex=/\./ // 定义正则表达式,查找小数点 |
| | | return regex.test(value) //返回true/false |
| | | } |
| | | |
| | | const hasDecimalhtml=(item,row)=>{ |
| | | let aa=item.split('.').length |
| | | if (aa===2){ |
| | | return row[item.split('.')[0]][item.split('.')[1]] |
| | | }else if(aa===3){ |
| | | return row[item.split('.')[0]][item.split('.')[1]][item.split('.')[2]] |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | let filterData = ref({}) |
| | | |
| | | let pageNum=ref(1) |
| | | let total = reactive({ |
| | | pageTotal : 0, |
| | | dataTotal : 0, |
| | | pageSize : 10 |
| | | }) |
| | | |
| | | //第一次调用 |
| | | request.post(`/customer/getseletCustomer/1/${total.pageSize}`,filterData.value).then((res) => { |
| | | |
| | | if(res.code==200){ |
| | | console.log(res.data) |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal= res.data.total.pageTotal |
| | | pageNum.value=1 |
| | | produceList = deepClone(res.data.data) |
| | | xGrid.value.loadData(produceList) |
| | | gridOptions.loading=false |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | |
| | | let pageState = null |
| | | |
| | | |
| | | const changeFilterEvent = (event, option, $panel,) => { |
| | | // 手动触发筛选 |
| | | $panel.changeOption(event, !!option.data, option) |
| | | } |
| | | function filterChanged(column){ |
| | | gridOptions.loading=true |
| | | //筛选条件发生变化条件发生变化 |
| | | let value = column.datas[0]!=undefined?column.datas[0]:'' |
| | | value = value.trim() |
| | | //判断是否存在外键 |
| | | if (column.property.indexOf('.')>-1){ |
| | | const columnArr = column.property.split('.') |
| | | filterData.value[columnArr[0]] = { |
| | | [columnArr[1]]:value |
| | | } |
| | | }else{ |
| | | filterData.value[column.property] = value |
| | | } |
| | | request.post(`/customer/getseletCustomer/1/${total.pageSize}`,filterData.value).then((res) => { |
| | | |
| | | if(res.code==200){ |
| | | console.log(res.data) |
| | | total.dataTotal = res.data.total.total*1 |
| | | total.pageTotal= res.data.total.pageTotal |
| | | pageNum.value=1 |
| | | produceList = deepClone(res.data.data) |
| | | xGrid.value.loadData(produceList) |
| | | gridOptions.loading=false |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | } |
| | | //分页查询 |
| | | const selectOrderList = ()=>{ |
| | | |
| | | request.post(`/customer/getseletCustomer/${pageNum.value}/${total.pageSize}`,filterData.value).then((res) => { |
| | | |
| | | if(res.code==200){ |
| | | console.log(res.data) |
| | | produceList = deepClone(res.data.data) |
| | | xGrid.value.loadData(produceList) |
| | | gridOptions.loading=false |
| | | }else{ |
| | | ElMessage.warning(res.msg) |
| | | router.push("/login") |
| | | } |
| | | }) |
| | | } |
| | | //页脚跳转 |
| | | const handlePageChange = ({ currentPage, pageSize }) => { |
| | | total.pageTotal = pageSize |
| | | pageNum.value=currentPage |
| | | |
| | | selectOrderList() |
| | | } |
| | | |
| | | |
| | | |
| | | //子组件接收参数 |
| | | |
| | | const xGrid = ref(); |
| | | const gridOptions = reactive({ |
| | | border: "full",//表格加边框 |
| | | keepSource: true,//保持源数据 |
| | |
| | | {type:'expand',fixed:"left",slots: { content:'content' },width: 50}, |
| | | {type: 'seq',fixed:"left", title: '自序', width: 80 }, |
| | | {title: '操作', width: 110, slots: { default: 'button_slot' },fixed:"left"}, |
| | | {field: '0', title: '客户编码',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '1', title: '名称',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '2', title: '客户等级',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '3', title: '信用额度',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '4', title: '地址',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '5', title: '联系人',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: '6', title: '联系电话',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true} |
| | | {field: 'id', title: '客户编码',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'customerName', title: '名称',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'grade', title: '客户等级',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'moneyLimit', title: '信用额度',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'address', title: '地址',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'contact', title: '联系人',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true}, |
| | | {field: 'phone', title: '联系电话',filters:[{ data: '' }],slots: { filter: 'num1_filter' }, sortable: true} |
| | | ],//表头按钮 |
| | | toolbarConfig: { |
| | | buttons: [], |
| | |
| | | zoom: true, |
| | | custom: true |
| | | }, |
| | | data: [ |
| | | { |
| | | '0':'1', |
| | | '1':'太仓卓高玻璃制品有限公司', |
| | | '2':'A', |
| | | '3':'100000', |
| | | '4':'江苏太仓xxxx街道', |
| | | '5':'张三', |
| | | '6':'139xxxxxxxx', |
| | | |
| | | }, |
| | | { |
| | | '0':'1', |
| | | '1':'山西某某公司', |
| | | '2':'A', |
| | | '3':'100000', |
| | | '4':'江苏太仓xxxx街道', |
| | | '5':'张三', |
| | | '6':'139xxxxxxxx', |
| | | |
| | | } |
| | | ],//table body实际数据 |
| | | footerMethod ({ columns, data }) {//页脚函数 |
| | | return[ |
| | | columns.map((column, columnIndex) => { |
| | |
| | | <ul class="expand-wrapper"> |
| | | <li v-for="(item,index) in gridOptions.columns" v-show="item.field!=undefined "> |
| | | <span style="font-weight: bold">{{item.title+': '}}</span> |
| | | <span>{{ row[item.field] }}</span> |
| | | <span v-if="hasDecimal(item.field)">{{ hasDecimalhtml(item.field,row) }}</span> |
| | | <span v-else>{{ row[item.field] }}</span> |
| | | </li> |
| | | </ul> |
| | | </template> |
| | |
| | | </div> |
| | | </template> |
| | | |
| | | <template #pager> |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | | :total="total.dataTotal" |
| | | > |
| | | </vxe-pager> |
| | | </template> |
| | | |
| | | |
| | | </vxe-grid> |
| | | </div> |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
| | |
| | | <!--使用 pager 插槽--> |
| | | <vxe-pager |
| | | @page-change="handlePageChange" |
| | | :layouts="[ 'PrevJump', 'PrevPage', 'Jump','PageCount', 'NextPage', 'NextJump', 'Total']" |
| | | :layouts="[ 'PrevPage', 'Jump','PageCount', 'NextPage', 'Total']" |
| | | v-model:current-page="pageNum" |
| | | v-model:page-size="total.pageSize" |
| | | v-model:pager-count="total.pageTotal" |
New file |
| | |
| | | package com.example.erp.controller.sd; |
| | | |
| | | |
| | | import com.example.erp.common.Constants; |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.entity.sd.Customer; |
| | | import com.example.erp.entity.sd.Delivery; |
| | | import com.example.erp.entity.sd.Order; |
| | | import com.example.erp.entity.sd.OrderDetail; |
| | | import com.example.erp.exception.ServiceException; |
| | | import com.example.erp.service.sd.CustomerService; |
| | | import com.example.erp.service.sd.DeliveryService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @RestController |
| | | @Api(value="客户controller",tags={"客户操作接口"}) |
| | | @RequestMapping("/customer") |
| | | public class CustomerController { |
| | | @Autowired |
| | | CustomerService customerService; |
| | | |
| | | |
| | | /*发货订单查询*/ |
| | | @ApiOperation("客户查询接口") |
| | | @PostMapping("/getseletCustomer/{pageNum}/{pageSize}") |
| | | public Result getseletShippingOrder(@PathVariable Integer pageNum, @PathVariable Integer pageSize, @RequestBody Customer customer){ |
| | | return Result.seccess(customerService.getseletCustomer(pageNum,pageSize,customer)); |
| | | } |
| | | |
| | | @ApiOperation("客户新增修改接口") |
| | | @PostMapping("/insertCustomer") |
| | | public Result insertCustomer( @RequestBody Map<String,Object> object){ |
| | | if(customerService.insertCustomer(object)){ |
| | | |
| | | return Result.seccess(); |
| | | |
| | | }else { |
| | | throw new ServiceException(Constants.Code_500,"客户新增/修改失败"); |
| | | |
| | | } |
| | | } |
| | | |
| | | @ApiOperation("客户删除接口") |
| | | @PostMapping("/deleteCustomer") |
| | | public Result deleteCustomer( @RequestBody Map<String,Object> object){ |
| | | if(customerService.deleteCustomer(object)){ |
| | | |
| | | return Result.seccess(); |
| | | |
| | | }else { |
| | | throw new ServiceException(Constants.Code_500,"客户删除失败"); |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | package com.example.erp.mapper.sd; |
| | | |
| | | import com.example.erp.entity.sd.Customer; |
| | | import com.example.erp.entity.sd.Delivery; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.data.repository.CrudRepository; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Mapper |
| | | public interface CustomerMapper { |
| | | public interface CustomerMapper extends CrudRepository<Customer,Long> { |
| | | |
| | | List<Customer> getCustomerList(); |
| | | List<Customer> getseletCustomer(@Param("offset") Integer offset, |
| | | @Param("pageSize") Integer pageSize, |
| | | @Param("customer") Customer customer); |
| | | |
| | | |
| | | Map<String,Integer> getseletCustomerPageTotal(Integer offset, Integer pageSize, Customer customer); |
| | | |
| | | Boolean insertCustomer(@Param("customer") Customer customer); |
| | | |
| | | Boolean updateCustomer(@Param("customer") Customer customer); |
| | | |
| | | Boolean deleteCustomer(@Param("customer") Customer customer); |
| | | } |
New file |
| | |
| | | package com.example.erp.service.sd; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.example.erp.entity.sd.*; |
| | | import com.example.erp.entity.userInfo.SysError; |
| | | import com.example.erp.mapper.mm.FinishedGoodsInventoryMapper; |
| | | import com.example.erp.mapper.sd.*; |
| | | import com.example.erp.service.userInfo.SysErrorService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @DS("sd") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public class CustomerService { |
| | | @Autowired |
| | | CustomerMapper customerMapper; |
| | | @Autowired |
| | | SysErrorService sysErrorService; |
| | | |
| | | |
| | | public Map<String, Object> getseletCustomer(Integer pageNum, Integer pageSize, Customer customer) { |
| | | Integer offset = (pageNum - 1) * pageSize; |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("data", customerMapper.getseletCustomer(offset, pageSize, customer)); |
| | | map.put("total", customerMapper.getseletCustomerPageTotal(offset, pageSize, customer)); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public Boolean insertCustomer(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | Customer customer = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Customer.class); |
| | | if(customer!=null){ |
| | | if (customer.getId()!=null){ |
| | | customerMapper.updateCustomer(customer); |
| | | }else{ |
| | | customerMapper.insertCustomer(customer); |
| | | } |
| | | |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | public Boolean deleteCustomer(Map<String,Object> object) { |
| | | boolean saveState = true; |
| | | //设置回滚点 |
| | | Object savePoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint(); |
| | | try { |
| | | Customer customer = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Customer.class); |
| | | if(customer!=null){ |
| | | if (customer.getId()!=null){ |
| | | customerMapper.deleteCustomer(customer); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | } catch (Exception e) { |
| | | TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savePoint); |
| | | //将异常传入数据库 |
| | | SysError sysError = new SysError(); |
| | | sysError.setError(e.toString()); |
| | | sysError.setFunc("saveOrder"); |
| | | sysErrorService.insert(sysError); |
| | | saveState = false; |
| | | |
| | | } |
| | | return saveState; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | if (object.get("deliveryId") != null) { |
| | | deliveryId = object.get("deliveryId").toString(); |
| | | } |
| | | Delivery delivery = JSONObject.parseObject(JSONObject.toJSONString(object.get("title")), Delivery.class); |
| | | Delivery delivery = JSONObject.parseObject(JSONObject.toJSONString(object.get("customer")), Delivery.class); |
| | | List<OrderDetail> orderDetaillist = JSONArray.parseArray(JSONObject.toJSONString(object.get("delivery")), OrderDetail.class); |
| | | //查询发货单是否存在 |
| | | Integer deliveryConut = deliveryMapper.getDeliveryConut(deliveryId); |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.example.erp.mapper.sd.CustomerMapper"> |
| | | |
| | | <select id="getCustomerList"> |
| | | select |
| | | * |
| | | from |
| | | customer |
| | | sd.customer |
| | | </select> |
| | | <select id="getseletCustomer"> |
| | | select |
| | | * |
| | | from |
| | | sd.customer c |
| | | <where> |
| | | <if test="customer.id != null and customer.id != ''"> |
| | | and c.id regexp #{customer.id} |
| | | </if> |
| | | <if test="customer.customerName != null and customer.customerName != ''"> |
| | | and c.customer_name regexp #{customer.customerName} |
| | | </if> |
| | | <if test="customer.grade != null and customer.grade != ''"> |
| | | and c.grade regexp #{customer.grade} |
| | | </if> |
| | | <if test="customer.moneyLimit != null and customer.moneyLimit != ''"> |
| | | and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','') |
| | | </if> |
| | | <if test="customer.address != null and customer.address != ''"> |
| | | and c.address regexp #{customer.address} |
| | | </if> |
| | | <if test="customer.contact != null and customer.contact != ''"> |
| | | and c.contact regexp #{customer.contact} |
| | | </if> |
| | | <if test="customer.phone != null and customer.phone != ''"> |
| | | and c.phone regexp #{customer.phone} |
| | | </if> |
| | | |
| | | </where> |
| | | limit #{offset},#{pageSize}; |
| | | </select> |
| | | |
| | | <select id="getseletCustomerPageTotal"> |
| | | select |
| | | CEILING(count(id)/#{pageSize}) as 'pageTotal', |
| | | count(id) as 'total' |
| | | from |
| | | sd.customer c |
| | | <where> |
| | | <if test="customer.id != null and customer.id != ''"> |
| | | and c.id regexp #{customer.id} |
| | | </if> |
| | | <if test="customer.customerName != null and customer.customerName != ''"> |
| | | and c.customer_name regexp #{customer.customerName} |
| | | </if> |
| | | <if test="customer.grade != null and customer.grade != ''"> |
| | | and c.grade regexp #{customer.grade} |
| | | </if> |
| | | <if test="customer.moneyLimit != null and customer.moneyLimit != ''"> |
| | | and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','') |
| | | </if> |
| | | <if test="customer.address != null and customer.address != ''"> |
| | | and c.address regexp #{customer.address} |
| | | </if> |
| | | <if test="customer.contact != null and customer.contact != ''"> |
| | | and c.contact regexp #{customer.contact} |
| | | </if> |
| | | <if test="customer.phone != null and customer.phone != ''"> |
| | | and c.phone regexp #{customer.phone} |
| | | </if> |
| | | |
| | | </where> |
| | | limit #{offset},#{pageSize}; |
| | | </select> |
| | | |
| | | <insert id="insertCustomer" useGeneratedKeys="true" > |
| | | insert into sd.customer(customer_name,grade,money_limit,address,contact,phone) |
| | | values ( |
| | | #{customer.customerName},#{customer.grade},#{customer.moneyLimit}, |
| | | #{customer.address},#{customer.contact},#{customer.phone} |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateCustomer" useGeneratedKeys="true" > |
| | | update sd.customer set customer_name=#{customer.customerName},grade=#{customer.grade}, |
| | | money_limit=#{customer.moneyLimit},address= #{customer.address}, |
| | | contact=#{customer.contact},phone=#{customer.phone} where id=#{customer.id} |
| | | </update> |
| | | |
| | | <delete id="deleteCustomer" > |
| | | delete from sd.customer where id=#{customer.id} |
| | | </delete> |
| | | </mapper> |
| | |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.example.erp.mapper.sd.CustomerMapper"> |
| | | |
| | | <select id="getCustomerList"> |
| | | select |
| | | * |
| | | from |
| | | customer |
| | | sd.customer |
| | | </select> |
| | | <select id="getseletCustomer"> |
| | | select |
| | | * |
| | | from |
| | | sd.customer c |
| | | <where> |
| | | <if test="customer.id != null and customer.id != ''"> |
| | | and c.id regexp #{customer.id} |
| | | </if> |
| | | <if test="customer.customerName != null and customer.customerName != ''"> |
| | | and c.customer_name regexp #{customer.customerName} |
| | | </if> |
| | | <if test="customer.grade != null and customer.grade != ''"> |
| | | and c.grade regexp #{customer.grade} |
| | | </if> |
| | | <if test="customer.moneyLimit != null and customer.moneyLimit != ''"> |
| | | and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','') |
| | | </if> |
| | | <if test="customer.address != null and customer.address != ''"> |
| | | and c.address regexp #{customer.address} |
| | | </if> |
| | | <if test="customer.contact != null and customer.contact != ''"> |
| | | and c.contact regexp #{customer.contact} |
| | | </if> |
| | | <if test="customer.phone != null and customer.phone != ''"> |
| | | and c.phone regexp #{customer.phone} |
| | | </if> |
| | | |
| | | </where> |
| | | limit #{offset},#{pageSize}; |
| | | </select> |
| | | |
| | | <select id="getseletCustomerPageTotal"> |
| | | select |
| | | CEILING(count(id)/#{pageSize}) as 'pageTotal', |
| | | count(id) as 'total' |
| | | from |
| | | sd.customer c |
| | | <where> |
| | | <if test="customer.id != null and customer.id != ''"> |
| | | and c.id regexp #{customer.id} |
| | | </if> |
| | | <if test="customer.customerName != null and customer.customerName != ''"> |
| | | and c.customer_name regexp #{customer.customerName} |
| | | </if> |
| | | <if test="customer.grade != null and customer.grade != ''"> |
| | | and c.grade regexp #{customer.grade} |
| | | </if> |
| | | <if test="customer.moneyLimit != null and customer.moneyLimit != ''"> |
| | | and c.money_limit regexp REGEXP_REPLACE(#{customer.moneyLimit},'\\.0+$','') |
| | | </if> |
| | | <if test="customer.address != null and customer.address != ''"> |
| | | and c.address regexp #{customer.address} |
| | | </if> |
| | | <if test="customer.contact != null and customer.contact != ''"> |
| | | and c.contact regexp #{customer.contact} |
| | | </if> |
| | | <if test="customer.phone != null and customer.phone != ''"> |
| | | and c.phone regexp #{customer.phone} |
| | | </if> |
| | | |
| | | </where> |
| | | limit #{offset},#{pageSize}; |
| | | </select> |
| | | |
| | | <insert id="insertCustomer" useGeneratedKeys="true" > |
| | | insert into sd.customer(customer_name,grade,money_limit,address,contact,phone) |
| | | values ( |
| | | #{customer.customerName},#{customer.grade},#{customer.moneyLimit}, |
| | | #{customer.address},#{customer.contact},#{customer.phone} |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateCustomer" useGeneratedKeys="true" > |
| | | update sd.customer set customer_name=#{customer.customerName},grade=#{customer.grade}, |
| | | money_limit=#{customer.moneyLimit},address= #{customer.address}, |
| | | contact=#{customer.contact},phone=#{customer.phone} where id=#{customer.id} |
| | | </update> |
| | | |
| | | <delete id="deleteCustomer" > |
| | | delete from sd.customer where id=#{customer.id} |
| | | </delete> |
| | | </mapper> |