| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- <template>
- <section>
- <!--工具条-->
- <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
- <el-form :inline="true">
- <el-form-item :label="$t('clientlist')">
-
- </el-form-item>
- <el-form-item >
- <div>
- <el-input style="float:left;" v-model="keyword" class="input-with-select" :placeholder="$t('pleaseenterthecustomernamekeyword')" @keyup.enter.native="searchList()" clearable="true">
- <el-button slot="append" @click="searchList" icon="el-icon-search"></el-button>
- </el-input>
- </div>
- </el-form-item>
- <el-form-item style="float:right;">
- <el-link type="primary" :underline="false" @click="handleAdd(-1,null)">{{ $t('newcustomer') }}</el-link>
- <el-link type="primary" :underline="false" @click="intocustomerRatio">{{ $t('importingCustomersinBatches') }}</el-link>
- <el-link type="primary" :underline="false" @click="exportData()">{{ $t('export.export') }}</el-link>
- </el-form-item>
- </el-form>
- </el-col>
- <!--列表-->
- <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @selection-change="selectionChange" @sort-change="tableSort">
- <el-table-column type="selection" width="60">
- <!-- <template slot-scope="scope" >
- {{scope.$index+1+(page-1)*size}}
- </template> -->
- </el-table-column>
- <el-table-column prop="customerCode" :label="$t('clientcode')" width="160" sortable="custom"></el-table-column>
- <el-table-column prop="customerName" :label="$t('customername')" >
- </el-table-column>
- <el-table-column prop="contactName" :label="$t('contact')" width="120">
- </el-table-column>
- <el-table-column prop="contactPhone" :label="$t('contactphonenumber')" width="150">
- </el-table-column>
- <el-table-column prop="email" :label="$t('email')" width="180">
- </el-table-column>
- <el-table-column prop="address" :label="$t('address')" sortable="custom">
- </el-table-column>
-
- <el-table-column :label="$t('operation')" width="150">
- <template slot-scope="scope">
- <el-button size="mini" type="primary" @click="handleAdd(scope.$index, scope.row)">{{ $t('bian-ji') }}</el-button>
- <el-button size="mini" @click="deletePro(scope.$index, scope.row)">{{ $t('btn.delete') }}</el-button>
- </template>
- </el-table-column>
- </el-table>
- <!--工具条-->
- <el-col :span="24" class="toolbar">
- <el-button type="primary" size="small" @click="batchDelete" :loading="delLoading">{{ $t('Batchdelete') }}</el-button>
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :page-sizes="[20 , 50 , 80 , 100]"
- :page-size="20"
- layout="total, sizes, prev, pager, next"
- :total="total"
- style="float:right;"
- ></el-pagination>
- </el-col>
- <!--新增界面-->
- <el-dialog :title="title" v-if="addFormVisible" :visible.sync="addFormVisible" :close-on-click-modal="false" customClass="customWidth" width="800px">
- <el-form ref="form1" :model="addForm" :rules="rules" label-width="120px">
- <el-form-item :label="$t('ustomernumber')" >
- <el-input v-model="addForm.customerCode" :max="20" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('customername')" prop="customerName">
- <el-input v-model="addForm.customerName" :max="20" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('contact')" prop="contactName">
- <el-input v-model="addForm.contactName" :max="20" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('contactphonenumber')" prop="contactPhone">
- <el-input v-model="addForm.contactPhone" :max="20" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('email')" prop="email">
- <el-input v-model="addForm.email" :max="25" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- <el-form-item :label="$t('address')" prop="address">
- <el-input v-model="addForm.address" :max="50" :placeholder="$t('peaseenterthe')" clearable></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer;">
- <el-button @click.native="addFormVisible = false">{{ $t('btn.cancel') }}</el-button>
- <el-button type="primary" @click="submitInsert" :loading="addLoading">{{ $t('btn.submit') }}</el-button>
- </div>
- </el-dialog>
- <!-- 导入结果说明 -->
- <el-dialog :title="$t('importingtheallocationratio')" v-if="showImportResult" :visible.sync="showImportResult" customClass="customWidth" width="500px">
- <div>
- <span>{{importResultMsg}}</span>
-
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" @click="showImportResult=false">{{ $t('btn.determine') }}</el-button>
- </span>
- </el-dialog>
- <el-dialog :title="$t('importingCustomerData')" v-if="intocustomerDialog" :visible.sync="intocustomerDialog" customClass="customWidth" width="500px">
- <p>1. {{ $t('other.download') }}
- <el-link type="primary" style="margin-left:5px;" :underline="false" :href="'./upload/'+$t('customerimporttemplatisadded')+'.xlsx'" :download="$t('customerimporttemplatisadded')+'.xlsx'">{{$t('customerimporttemplatisadded')}}.xlsx</el-link>
- </p>
- <!-- <p>2. 填写excel模板,请确保模板中的项目和人员已添加到系统中。</p> -->
- <p style="display: flex;justify-content: center;padding:1em 0">
- <el-upload ref="upload" action="#" :limit="1" :http-request="batchImportData" :show-file-list="false">
- <el-button type="primary" :underline="false" :loading="importingData">{{ $t('other.startImporting') }}</el-button>
- </el-upload>
- </p>
- </el-dialog>
- </section>
- </template>
- <style scoped>
- .input-with-select .el-input-group__prepend {
- background-color: #fff;
- }
- .line {
- padding:10px;
- }
- .line span{
- font-size:15px;
- }
- .line span:nth-child(even){
- float:right;
- }
- </style>
- <script>
- import util from "../../common/js/util";
- export default {
- data() {
- return {
- roleArray:[this.$t('role.ordinaryEmployees'),this.$t('role.superAdministrator'), this.$t('role.systemAdministrator'), this.$t('role.companyTop'),this.$t('role.financialAdministrator'), this.$t('role.projectManager')],
- status:null,
- statusTxt:["-",this.$t('ongoing'),this.$t('state.completed'),this.$t('state.undone')],
- importanceList:[{id:1,label:this.$t('zheng-chang')},{id:2,label:this.$t('jin-ji')},{id:3,label:this.$t('zhong-yao')},{id:4,label:this.$t('zhong-yao-qie-jin-ji')}],
- searchField:null,
- keyword:null,
- user: JSON.parse(sessionStorage.getItem("user")),
- userDetailVisible: false,
- userDetail:{},
- date: new Date(),
- users: [],
- participator:[],
- tableHeight: 0,
- listLoading: false,
- total: 0,
- page: 1,
- size: 20,
- list: [],
- subProjectVisible: false,
- subProjectList: [],//子项目列表
- currentProject:{},
- addSubProject: false,
- addFormVisible: false,
- addLoading: false,
- addUp: 0, // 合计
- title: "",
- addForm: {
- name: '',
- userId: [],
- level:1,
- },
- rules: {
- customerName: [{ required: true, message: this.$t('pleaseenterthecustomername'), trigger: "blur" }],
- },
- intocustomerDialog:false,
- importingData: false,
- importResultMsg:null,
- showImportResult:false,
- selectArr: [],
- delLoading: false,
- sortOrder: null,
- sortProp: ''
- };
- },
- // 过滤器
- filters: {
- numberToCurrency(value) {
- if (!value) return '0.00'
- // 将数值截取,保留两位小数
- value = value.toFixed(2)
- // 获取整数部分
- const intPart = Math.trunc(value)
- // 整数部分处理,增加,
- const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
- // 预定义小数部分
- let floatPart = '.00'
- // 将数值截取为小数部分和整数部分
- const valueArray = value.toString().split('.')
- if (valueArray.length === 2) { // 有小数部分
- floatPart = valueArray[1].toString() // 取得小数部分
- return intPartFormat + '.' + floatPart
- }
- return intPartFormat + floatPart
- }
- },
- methods: {
- // 批量删除
- selectionChange(selection){
- console.log('sel',selection);
- this.selectArr = selection
- },
- batchDelete(){
- if(this.selectArr.length == 0){
- this.$message(this.$t('selecttheustomerdatayouwanttodelete'))
- return
- }else{
- let nametext = ''
- for(let i in this.selectArr){
- nametext += this.selectArr[i].customerName + '、'
- }
- nametext = nametext.substring(0,nametext.length - 1)
- this.$confirm(this.$t('determinethatyouwantodelete') +":" + nametext + "\u3000"+this.$t('ma')+"?",this.$t('deleteCustomer'), {
- confirmButtonText: this.$t('btn.determine'),
- cancelButtonText: this.$t('btn.cancel'),
- type: "warning"
- }).then(()=>{
- this.delLoading = true
- let batchIds = ''
- for(let m in this.selectArr){
- batchIds += this.selectArr[m].id + ','
- }
- batchIds = batchIds.substring(0,batchIds.length - 1)
- this.http.post('/customer-info/batchDelete',{
- batchIds
- },res => {
- this.delLoading = false
- if(res.code == 'ok'){
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: 'success'
- })
- this.getList()
- }else {
- this.$message({
- message: res.msg,
- type: 'error'
- })
- }
- },err => {
- this.delLoading = false
- this.$message({
- message: res.msg,
- type: 'error'
- })
- })
- })
-
- }
- },
- intocustomerRatio(){
- this.intocustomerDialog=true;
- },
- batchImportData(item) {
- //首先判断文件类型
- let str = item.file.name.split(".");
- let format = str[str.length - 1];
- if (format != "xls" && format != "xlsx") {
- this.$message({
- message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
- type: "error"
- });
- } else {
- this.importingData = true;
- let formData = new FormData();
- formData.append("file", item.file);
- this.http.uploadFile('/customer-info/importData', formData,
- res => {
- this.$refs.upload.clearFiles();
- this.importingData = false;
- this.showImportResult = true;
- if (res.code == "ok") {
- //换成弹出框,以免有人等了半天回来啥也没看到
- this.importResultMsg = this.$t('importedupdatedsuccessfully')+res.data+this.$t('customerdata')+(res.msg?res.msg:"");
- this.getList();
- } else {
- this.importResultMsg = this.$t('export.Importfailure')+":"+res.msg;
- }
- },
- error => {
- this.$refs.upload.clearFiles();
- this.importingData = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- importProject(item) {
- //首先判断文件类型
- let str = item.file.name.split(".");
- let format = str[str.length - 1];
- if (format != "xls" && format != "xlsx") {
- this.$message({
- message: this.$t('other.PleaseselecttheXLSorXLSXfile'),
- type: "error"
- });
- } else {
- this.listLoading = true;
- let formData = new FormData();
- formData.append("file", item.file);
- formData.append("userId", this.user.id);
- this.http.uploadFile('/project/importData', formData,
- res => {
- this.$refs.upload.clearFiles();
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: this.$t('other.importSuccess'),
- type: "success"
- });
- this.getList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$refs.upload.clearFiles();
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- },
- number(){
- // this.addForm.budget = this.addForm.budget.replace(/[^\.\d]/g,'');
- // this.addForm.budget = this.addForm.budget.replace('.','');
- },
- deleteSubPro(subProject) {
- this.$confirm(this.$t('makesuretodeletethesubproject') + subProject.name + this.$t('ma'),this.$t('deletesubproject'), {
- confirmButtonText: this.$t('btn.determine'),
- cancelButtonText: this.$t('btn.cancel'),
- type: "warning"
- })
- .then(() => {
- this.listLoading = true;
- this.http.post('/sub-project/deleteProject',{
- id: subProject.id
- },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: "success"
- });
- this.subProject(this.currentProject);
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- })
- .catch(() => {});
- },
- searchList() {
- this.page = 1;
- this.getList();
- },
- addNewSubProject(subProject) {
- console.log(123);
- if (subProject == null) {
- this.addForm = {projectId: this.currentProject.id, level:1}
- } else {
- this.addForm = subProject;
- }
- this.addSubProject = true;
- },
- //显示子项目
- subProject(item) {
- this.subProjectVisible = true;
- this.currentProject = item;
- this.http.post('/sub-project/list', {
- projectId: item.id
- },
- res => {
- if (res.code == "ok") {
- this.subProjectList = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- //显示用户详情
- showUser(userId) {
- this.userDetailVisible = true;
- this.http.post(this.port.manage.userDetail, {
- userId: userId
- },
- res => {
- if (res.code == "ok") {
- this.userDetail = res.data;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
-
-
- //分页
- handleCurrentChange(val) {
- this.page = val;
- this.getList();
- },
- handleSizeChange(val) {
- this.size = val;
- this.getList();
- },
- tableSort({column, prop, order}){
- if(prop == 'customerCode' || prop == 'address'){
- this.sortOrder = order
- this.sortProp = prop
- this.getList()
- }
- },
- //获取项目列表
- getList() {
- this.listLoading = true;
- let parameter = {
- pageIndex: this.page,
- pageSize: this.size,
- keyword:this.keyword
- }
- if(this.sortOrder){
- if(this.sortProp == 'customerCode'){
- parameter.sortProp = 'customer_code'
- }else if(this.sortProp == 'address'){
- parameter.sortProp = 'address'
- }
- if(this.sortOrder == 'descending'){
- parameter.sortOrder = 0
- }else if(this.sortOrder == 'ascending'){
- parameter.sortOrder = 1
- }
- }
- this.http.post('/customer-info/list', parameter,
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- var list = res.data.records;
- this.list = list;
- this.total = res.data.total;
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- //显示新增界面
- handleAdd(i, item) {
- if(i == -1) {
- this.title = this.$t('newcustomer');
- this.addForm = {
- }
- } else {
- this.title = this.$t('modifythecustomer');
- this.addForm = JSON.parse(JSON.stringify(item));
- }
- this.addFormVisible = true;
- },
- submitInsert() {
- this.$refs.form1.validate(valid => {
- if (valid) {
- this.addLoading = true;
- this.http.post('/customer-info/addOrMod', this.addForm,
- res => {
- this.addLoading = false;
- if (res.code == "ok") {
- this.addFormVisible = false;
- this.getList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.addLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- });
- }
- });
- },
- // 删除
- deletePro(i, item) {
- this.$confirm(this.$t('makeuretodeletethecustomer') + item.customerName + this.$t('ma'),this.$t('deleteCustomer'), {
- confirmButtonText: this.$t('btn.determine'),
- cancelButtonText: this.$t('btn.cancel'),
- type: "warning"
- })
- .then(() => {
- this.listLoading = true;
- this.http.post('/customer-info/delete',{
- id: item.id
- },
- res => {
- this.listLoading = false;
- if (res.code == "ok") {
- this.$message({
- message: this.$t('message.successfullyDeleted'),
- type: "success"
- });
- this.getList();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.listLoading = false;
- this.$message({
- message: error,
- type: "error"
- });
- }
- );
- })
- .catch(() => {});
- },
- exportData(){
- this.http.post('/customer-info/exportData', {},
- res => {
- if (res.code == "ok") {
- var filePath = res.data;
- const a = document.createElement('a'); // 创建a标签
- a.setAttribute('download', this.$t('keHuLieBiaoXlsx'));// download属性
- a.setAttribute('href', filePath);// href链接
- a.click(); //自执行点击事件
- a.remove();
- } else {
- this.$message({
- message: res.msg,
- type: "error"
- });
- }
- },
- error => {
- this.$message({
- message: error,
- type: "error"
- });
- });
- },
- },
- created() {
- let height = window.innerHeight;
- this.tableHeight = height - 195;
- const that = this;
- window.onresize = function temp() {
- that.tableHeight = window.innerHeight - 195;
- };
- },
- mounted() {
- this.getList();
- }
- };
- </script>
- <style lang="scss" scoped>
- .rg_span{
- display: inline-block;
- }
- .rg_span span {
- text-align: right;
- box-sizing: border-box;
- padding-right: 10px;
- }
- .el-dialog__title {
- display: inline-table;
- margin-top: 20px;
- }
- </style>
|