123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- /**
- * Created by xieli on 2018/7/12 0012.
- */
- import http from "api/http.js";
- const mixins = {
- filters: {
- // 显示时间为 2021.07.22
- formatTime(time){
- if(time==='0001-01-01 00:00:00'||time==='0000-00-00 00:00:00'){
- return '--'
- }else{
- return time?time.replace(/-/g,'.'):''
- }
-
- },
- // 格式化金额 三位一个逗号
- formatPriceHasPoint(e){
- let str=e.toString()
- let num1='',num2=''
- if(str.indexOf(".")!=-1){
- num1=str.substring(0,str.indexOf("."))
- num2=str.substring(str.length,str.indexOf("."))
- if(Number(num2)<=0){
- num2=''
- }
- }else{
- num1=str
- }
- return num1.replace(/(?!^)(?=(\d{3})+$)/g, ',')+num2
- }
- },
- methods: {
- formatterColumn(row,column,cellvalue){
- return cellvalue ? http.dateFormatter(cellvalue) : '';
- },
- notHasTimeFormatter(row,column,cellvalue){
-
- return cellvalue ? http.dateFormatter(cellvalue,false) : '';
- },
- mixinsDateFormatter(date,type){
- if(!date) return "";
- return type === false ? http.dateFormatter(date, false) : http.dateFormatter(date);
- },
- numberFormatter(str,type=1){ // 0 文字在左侧 1 文字在右侧
- switch (str) {
- case '万':
- return (row,column,cellvalue) =>{
- return type ? `${this.division(cellvalue,10000)}${str}`:`${str}${this.division(cellvalue,10000)}`;
- };
- default:
- return (row,column,cellvalue) =>{
- return `${cellvalue}${str}`;
- };
- }
- },
- formatterTime(time){
- return http.dateFormatter(time);
- },
- /**
- * y 被除数
- * n 除数
- */
- division(y,n){ //除法
- if( y === '' || y===null || y===undefined){
- y = 0;
- }
- let a = String(y);
- let power = String(a).split('.')[1] ? String(a).split('.')[1].length : 0;
- let intY = y * Math.pow(10,power);
- let intN = n * Math.pow(10,power);
- return intY/intN;
- },
- prompt(msg) { //提示
- this.$message({
- message: msg,
- duration: 1000,
- });
- },
- notice(msg) {
- this.$message({
- message: msg,
- type: 'error',
- duration: 1000,
- });
- },
- success(msg) {
- this.$message({
- message: msg,
- type: 'success',
- duration: 1000,
- });
- },
- _handleFocus(){
- this.$nextTick(()=>{
- var a= document.getElementsByClassName('el-icon-arrow-right');
- a[1].removeAttribute('disabled');
- a[1].classList.remove('is-disabled');
- })
- },
- _sendCode(params,func){
- return new Promise( (resolve,reject)=>{
- this.$prompt('请输入验证码', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- inputValidator:(e)=>{
- if( e=='' || e==null ){
- return '验证码不能为空';
- }else{
- return true;
- }
- },
- beforeClose:(action,instance,done) => {
- if( action==='confirm' ){
- let newParams = Object.assign({},params,{VerifyCode:instance.inputValue});
- func(newParams).then(res=>{
- if( res.Ret==200 ){
- done();
- resolve(res);
- }
- })
- }else{
- done();
- }
- }
- }).then(({ value }) => {
-
- }).catch(() => {
- // this.$message({
- // type: 'info',
- // message: '取消输入'
- // });
- });
- })
- }
-
- }
- }
- export { mixins }
|