Commit b2f6ad32 by 杨明

fixed

1 parent c66f3130
export function debounce(fn, delay, triggerNow) {
var t = null;
console.log('ceshi')
var debounced = function(){
var _self = this,
args = arguments;
if(t){
clearTimeout(t);
}
if(triggerNow){
var exec = !t;
t = setTimeout(function(){
t = null;
}, delay);
var t = null
console.log('ceshi')
var debounced = function() {
var _self = this,
args = arguments
if (t) {
clearTimeout(t)
}
if (triggerNow) {
var exec = !t
if(exec){
// 初次进来
fn.apply(_self, args);
}
}else{
t = setTimeout(function(){
fn.apply(_self, args);
}, delay);
t = setTimeout(function() {
t = null
}, delay)
if (exec) {
// 初次进来
fn.apply(_self, args)
}
} else {
t = setTimeout(function() {
fn.apply(_self, args)
}, delay)
}
}
debounced.remove = function(){
clearTimeout(t);
t = null;
debounced.remove = function() {
clearTimeout(t)
t = null
}
return debounced;
}
return debounced
}
//格式化日期
export const formatDate = (date, fmt) => {
  if (!date) {
    date = new Date();
  }
  let o = {
    "M+": date.getMonth() + 1, //月份
    "d+": date.getDate(), //日
    "h+": date.getHours(), //小时
    "m+": date.getMinutes(), //分
    "s+": date.getSeconds(), //秒
    "q+": Math.floor((date.getMonth() + 3) / 3), //季度
    S: date.getMilliseconds(), //毫秒  1-3 位  只能一位占位符
    "U+": date.getMilliseconds() //毫秒   可以1-3位占位符
  };
  fmt = fmt || "yyyy-MM-dd hh:mm";
  if (/(y+)/.test(fmt))
    fmt = fmt.replace(
      RegExp.$1,
      (date.getFullYear() + "").substr(4 - RegExp.$1.length)
    );
  for (let k in o)
    if (new RegExp("(" + k + ")").test(fmt))
      fmt = fmt.replace(
        RegExp.$1,
        RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)
      );
  return fmt;
};
export const formatDate = (date, fmt) => {
if (!date) {
date = new Date()
}
let o = {
'M+': date.getMonth() + 1, //月份
'd+': date.getDate(), //日
'h+': date.getHours(), //小时
'm+': date.getMinutes(), //分
's+': date.getSeconds(), //秒
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
S: date.getMilliseconds(), //毫秒  1-3 位  只能一位占位符
'U+': date.getMilliseconds() //毫秒   可以1-3位占位符
}
fmt = fmt || 'yyyy-MM-dd hh:mm'
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
for (let k in o) if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
return fmt
}
//正则表示式是干什么的? 字符串匹配利器(难,规则多)
export function formatDate2(date, fmt) {
//1.获取年份
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
}
//2.获取
//M+ ->正则表达式一个规则
......@@ -79,16 +69,16 @@ export function formatDate2(date, fmt) {
'h+': date.getHours(),
'm+': date.getMinutes(),
's+': date.getSeconds()
};
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
let str = o[k] + '';
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str));
let str = o[k] + ''
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : padLeftZero(str))
}
}
return fmt;
};
return fmt
}
//填补左边的零(一般返回字符串最后两位)
function padLeftZero (str) {
return ('00' + str).substr(str.length);
};
function padLeftZero(str) {
return ('00' + str).substr(str.length)
}
import { Message } from 'element-ui'
let util = {}
util.cloneText = function (message) {
let input = document.createElement('input')
input.value = message
document.body.appendChild(input)
input.select()
input.setSelectionRange(0, input.value.length), document.execCommand('Copy')
document.body.removeChild(input)
Message.success('复制成功')
util.cloneText = function(message) {
let input = document.createElement('input')
input.value = message
document.body.appendChild(input)
input.select()
input.setSelectionRange(0, input.value.length), document.execCommand('Copy')
document.body.removeChild(input)
Message.success('复制成功')
}
util.getBeforeDate = function (sign = '-') {
let day = new Date();
let month = day.getMonth() + 1;
let date = day.getDate();
if (month < 10) month = '0' + month;
if (date < 10) date = '0' + date;
var s = day.getFullYear() + sign + month + sign + date;
return s;
util.getBeforeDate = function(sign = '-') {
let day = new Date()
let month = day.getMonth() + 1
let date = day.getDate()
if (month < 10) month = '0' + month
if (date < 10) date = '0' + date
var s = day.getFullYear() + sign + month + sign + date
return s
}
util.getBeforeMonth = function (days) {
let month = new Date().getMonth() + 1;
let year = new Date().getFullYear();
let arr = new Array();
for (let i = 0; i < days; i++) {
if (month <= 0) {
year = year - 1;
month = month + 12;
}
if (month < 10) month = '0' + month;
arr[i] = year + '年' + month + '月'
month--
util.getBeforeMonth = function(days) {
let month = new Date().getMonth() + 1
let year = new Date().getFullYear()
let arr = new Array()
for (let i = 0; i < days; i++) {
if (month <= 0) {
year = year - 1
month = month + 12
}
return arr;
if (month < 10) month = '0' + month
arr[i] = year + '年' + month + '月'
month--
}
return arr
}
/**
* 格式化时间
* @param {Array} time
*/
util.formatTime = function (time) {
return {
startTime: time ? time[0] + ' ' + '00:00:00' : '',
endTime: time ? time[1] + ' ' + '23:59:59' : ''
}
util.formatTime = function(time) {
return {
startTime: time ? time[0] + ' ' + '00:00:00' : '',
endTime: time ? time[1] + ' ' + '23:59:59' : ''
}
}
util.tringToDate = function (dateStr, separator) {
if (!separator) {
separator = "-";
}
var dateArr = dateStr.split(separator);
var year = parseInt(dateArr[0]);
var month;
//处理月份为04这样的情况
if (dateArr[1].indexOf("0") == 0) {
month = parseInt(dateArr[1].substring(1));
} else {
month = parseInt(dateArr[1]);
}
var day = parseInt(dateArr[2]);
var date = new Date(year, month - 1, day);
return date;
util.tringToDate = function(dateStr, separator) {
if (!separator) {
separator = '-'
}
var dateArr = dateStr.split(separator)
var year = parseInt(dateArr[0])
var month
//处理月份为04这样的情况
if (dateArr[1].indexOf('0') == 0) {
month = parseInt(dateArr[1].substring(1))
} else {
month = parseInt(dateArr[1])
}
var day = parseInt(dateArr[2])
var date = new Date(year, month - 1, day)
return date
}
util.getDay = function (num, str = '-') {
var today = new Date();
var nowTime = today.getTime();
var ms = 24 * 3600 * 1000 * num;
today.setTime(parseInt(nowTime + ms));
var oYear = today.getFullYear();
var oMoth = (today.getMonth() + 1).toString();
if (oMoth.length <= 1) oMoth = '0' + oMoth;
var oDay = today.getDate().toString();
if (oDay.length <= 1) oDay = '0' + oDay;
return oYear + str + oMoth + str + oDay;
util.getDay = function(num, str = '-') {
var today = new Date()
var nowTime = today.getTime()
var ms = 24 * 3600 * 1000 * num
today.setTime(parseInt(nowTime + ms))
var oYear = today.getFullYear()
var oMoth = (today.getMonth() + 1).toString()
if (oMoth.length <= 1) oMoth = '0' + oMoth
var oDay = today.getDate().toString()
if (oDay.length <= 1) oDay = '0' + oDay
return oYear + str + oMoth + str + oDay
}
util.openUrl = function (url) {
const link = document.createElement('a')
link.href = url
link.target = '_blank'
link.rel = 'opener'
link.click()
util.openUrl = function(url) {
const link = document.createElement('a')
link.href = url
link.target = '_blank'
link.rel = 'opener'
link.click()
}
util.debounce = function(fn, timer) {
var t = null
return function() {
if (t) {
clearTimeout(t)
}
t = setTimeout(() => {
fn.apply(this, arguments)
}, timer)
}
}
util.downloadIamge = function (imgsrc, name = new Date().getTime()) {
//下载图片地址和图片名
var image = new Image();
// 解决跨域 Canvas 污染问题
image.setAttribute("crossOrigin", "anonymous");
image.onload = function () {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var context = canvas.getContext("2d");
context.drawImage(image, 0, 0, image.width, image.height);
var url = canvas.toDataURL("image/png"); //得到图片的base64编码数据
util.downloadIamge = function(imgsrc, name = new Date().getTime()) {
//下载图片地址和图片名
var image = new Image()
// 解决跨域 Canvas 污染问题
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function() {
var canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
var context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
var url = canvas.toDataURL('image/png') //得到图片的base64编码数据
var a = document.createElement("a"); // 生成一个a元素
var event = new MouseEvent("click"); // 创建一个单击事件
a.download = name || "photo"; // 设置图片名称
a.href = url; // 将生成的URL设置为a.href属性
a.dispatchEvent(event); // 触发a的单击事件
};
image.src = imgsrc;
var a = document.createElement('a') // 生成一个a元素
var event = new MouseEvent('click') // 创建一个单击事件
a.download = name || 'photo' // 设置图片名称
a.href = url // 将生成的URL设置为a.href属性
a.dispatchEvent(event) // 触发a的单击事件
}
image.src = imgsrc
}
export default util
\ No newline at end of file
export default util
......@@ -46,7 +46,17 @@
</div>
<p>
<span>联系电话:</span>
<span class="ellipsis-1">{{ leftPanelInfo.customerPhone }}</span>
<span class="ellipsis-1" v-if="leftPanelInfo.customerPhone">{{ leftPanelInfo.customerPhone }}</span>
<span
class="phone-fill"
v-else
@click="
phoneVisible = true
contactPhone = ''
"
>
待完善
</span>
</p>
<p>
<span>证件号码:</span>
......@@ -225,6 +235,12 @@
<el-button type="primary" @click="goBack">返回</el-button>
</div>
</div>
<basic-dialog class="phone-fill-box" title="添加联系电话" :isVisible="phoneVisible" @confirmDialog="phoneConfirmDialog" @closeDialog="phoneVisible = false">
<div class="dialog-form">
<label>联系电话:</label>
<el-input v-model.trim="contactPhone" size="small" placeholder="请输入11位的手机号" maxlength="11"></el-input>
</div>
</basic-dialog>
<basic-dialog class="tags" :title="tagsDialogTitle" :width="'712px'" :isDestroyClose="true" :btnLoading="sloading" :isShowThirdBtn="true" :isShowCloseBtn="true" @btnEvent="goNewTag" :isVisible="tagsVisible" @confirmDialog="handleConfirm" @closeDialog="handleClose">
<slot>
<p class="hint-text color-6">
......@@ -273,6 +289,7 @@ export default {
},
data() {
return {
contactPhone: '',
isShowBaseInfo: true,
isShowTooltip: false,
remark: '',
......@@ -551,7 +568,7 @@ export default {
//弹窗数据
tagsDialogTitle: '设置标签',
tagsVisible: false,
phoneVisible: false,
companyTagsList: [],
ownShopTagsList: [],
......@@ -776,6 +793,17 @@ export default {
})
this.handleClose()
},
phoneConfirmDialog() {
if (!this.contactPhone) {
this.$message.error('请输入联系号码')
return
}
if (!/^1[3456789]\d{9}$/.test(this.contactPhone)) {
this.$message.error('联系号码格式错误')
return
}
this.phoneVisible = false
},
handleConfirm() {
this.sloading = true
let labelIdAddList = [] // 新增的标签
......@@ -877,6 +905,22 @@ export default {
.pure-yello-text {
color: #fb8f28;
}
.phone-fill {
font-size: 14px;
font-weight: 400;
color: #5850ff !important;
line-height: 20px;
text-decoration: underline;
cursor: pointer;
}
.dialog-form {
display: flex;
align-items: center;
padding: 30px;
label {
width: 100px;
}
}
.newStyle {
display: flex;
font-size: 14px;
......
......@@ -656,7 +656,7 @@ export default {
}
},
destroyed() {
window.removeEventListener('scroll', this.initHeight)
window.removeEventListener('scroll', this.initHeight, true)
}
}
</script>
......@@ -895,7 +895,7 @@ export default {
width: 100%;
background: #ffffff;
box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
z-index:999;
z-index: 999;
.el-button:nth-child(2) {
margin-left: 20px;
}
......
<template>
<div class="content-wrap">
<div class="tree-input">
<el-input placeholder="请输入标签组或标签关键字" v-model="filterText" size="small"><i slot="suffix" class="el-input__icon el-icon-search"></i></el-input>
<span @click="resetTree">重置</span>
</div>
<el-tree @check="checkChange" class="tag-tree" ref="tagTree" :data="labelTree" :props="defaultProps" show-checkbox node-key="id" default-expand-all :expand-on-click-node="false" :filter-node-method="filterNode">
<div class="custom-tree-node" slot-scope="{ node, data }">
<span class="tree-node">{{ node.label }}</span>
<span v-if="data.labelType" @click="editTree(data)">
<i class="el-icon-edit-outline"></i>
</span>
</div>
</el-tree>
</div>
</template>
<script>
import { getTableList } from '@/api/modules/tagsManage'
export default {
name: 'tagGroup',
data() {
return {
loading: false,
heightBox: 200,
dialogVisible: false,
filterText: '',
selectNum: 0,
searchStatus: false,
labelTree: [],
defaultProps: {
children: 'children',
label: 'name'
}
}
},
watch: {
filterText(val) {
this.$refs.tagTree.filter(val)
}
},
methods: {
resetTree() {
this.$refs.tagTree.setCheckedKeys([])
this.$emit('getCheckItem', this.$refs.tagTree)
},
filterNode(value, data) {
if (!value) return true
return data.name.indexOf(value) !== -1
},
//勾选
checkChange() {
this.$emit('getCheckItem', this.$refs.tagTree)
},
getTreeNode(item) {
let tree_id = []
item.forEach(group_item => {
group_item.children.forEach(label_item => {
label_item && tree_id.push(label_item.id)
})
})
this.$refs.tagTree.setCheckedKeys(tree_id)
},
editTree(data) {
this.$emit('editTag', 'edit', data.labelDTO)
},
getTableList() {
let params = {
labelTreeReq: {
pageNum: 1,
pageSize: 1000,
shopId: this.$globalState.session.merchantId,
labelGroupName: this.filterText,
edition: this.$globalState.session.merchantModel
}
}
getTableList(params).then(res => {
const labelTreeRets = res.labelTreeRets.map(item => {
return {
id: item.labelGroup.id,
name: item.labelGroup.name,
children: item.labelList,
labelType: item.labelType,
labelDTO: item
}
})
labelTreeRets.forEach(item => {
const index = this.labelTree.findIndex(ret => ret.name == item.labelType)
if (index == -1) {
this.labelTree.push({
id: item.id + '000',
name: item.labelType,
children: [item]
})
} else {
this.labelTree[index].children.push(item)
}
})
// console.log(this.labelTree)
})
}
},
mounted() {
this.getTableList()
}
}
</script>
<style lang="scss" scoped>
.content-wrap {
padding: 16px;
box-sizing: border-box;
height: 100%;
.tree-input {
display: flex;
align-items: center;
span {
display: inline-block;
color: #5850ff;
font-size: 14px;
width: 40px;
margin-left: 6px;
cursor: pointer;
}
}
.tag-tree {
margin-top: 20px;
height: calc(100% - 100px);
overflow-y: auto;
/deep/ {
.el-tree-node {
.el-tree-node__content {
height: 30px;
> .el-checkbox {
display: none;
}
}
}
.el-tree-node__children {
.el-tree-node__content {
.el-checkbox {
display: block;
}
}
}
.custom-tree-node {
font-size: 14px;
color: #333;
}
.tree-node {
width: 140px;
display: inline-block;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.el-tree-node__expand-icon {
font-size: 15px;
margin-top: -2px;
color: #000000;
}
.el-tree-node__expand-icon.is-leaf {
color: transparent;
}
.el-checkbox__inner {
margin-right: 10px;
}
.el-icon-edit-outline {
color: #5850ff;
font-size: 15px;
cursor: pointer;
}
}
}
}
</style>
......@@ -8,99 +8,92 @@ const baseUrl = '/'
const resolve = dir => path.join(__dirname, dir)
const CDN_DOMAIN = 'https://img02.glsx.com.cn/'
const cdn = {
css: [
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/theme-chalk/index.css`
],
js: [
`${CDN_DOMAIN}ajax/libs/vue/2.6.11/vue.min.js`,
`${CDN_DOMAIN}ajax/libs/vue-router/3.2.0/vue-router.min.js`,
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/index.js`,
`${CDN_DOMAIN}ajax/libs/vuex/3.6.2/vuex.min.js`,
// `${CDN_DOMAIN}ajax/libs/axios/0.21.0/axios.min.js`,
`${CDN_DOMAIN}ajax/libs/echarts/5.1.2/echarts.min.js`
]
css: [`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/theme-chalk/index.css`],
js: [
`${CDN_DOMAIN}ajax/libs/vue/2.6.11/vue.min.js`,
`${CDN_DOMAIN}ajax/libs/vue-router/3.2.0/vue-router.min.js`,
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/index.js`,
`${CDN_DOMAIN}ajax/libs/vuex/3.6.2/vuex.min.js`,
// `${CDN_DOMAIN}ajax/libs/axios/0.21.0/axios.min.js`,
`${CDN_DOMAIN}ajax/libs/echarts/5.1.2/echarts.min.js`
]
}
module.exports = {
outputDir: `../dist/${packageName}`,
publicPath,//node_env ? baseUrl : '/'
assetsDir: 'static',
configureWebpack: {
resolve: {
alias: {
'@': resolve('src'),
assets: resolve('src/assets'),
views: resolve('src/views'),
components: resolve('src/components'),
// 'jquery': 'jquery'
}
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery', // 创建 '$'、'jQuery'、'window.jQuery' 三个变量指向依赖jquery
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
],
output: {
library: `${packageName}-[name]`,
libraryTarget: 'umd', // 把微应用打包成 umd 库格式
jsonpFunction: `webpackJsonp_${packageName}`
},
externals: {
'vue': 'Vue',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'axios': 'axios',
'echarts': 'echarts'
}
outputDir: `../dist/${packageName}`,
publicPath, //node_env ? baseUrl : '/'
assetsDir: 'static',
configureWebpack: {
resolve: {
alias: {
'@': resolve('src'),
assets: resolve('src/assets'),
views: resolve('src/views'),
components: resolve('src/components')
// 'jquery': 'jquery'
}
},
devServer: {
hot: true,
disableHostCheck: true,
host: process.env.VUE_APP_HOST,
port: process.env.VUE_APP_PORT,
headers: {
'Access-Control-Allow-Origin': '*' // 主应用获取子应用时跨域响应头
},
// proxy: {    
// '/api': {        
// target: 'http://rop-merchant.test.glsx.com.cn',
//         
// changeOrigin: true,
//         
// pathRewrite: {            
// '^/api': '/'        
// }    
// },
// },
plugins: [
new webpack.ProvidePlugin({
$: 'jquery', // 创建 '$'、'jQuery'、'window.jQuery' 三个变量指向依赖jquery
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
],
output: {
library: `${packageName}-[name]`,
libraryTarget: 'umd', // 把微应用打包成 umd 库格式
jsonpFunction: `webpackJsonp_${packageName}`
},
chainWebpack: config => {
config.plugin('html')
.tap(args => {
// args[0].minify.removeComments = false;
args[0].cdn = cdn
return args
})
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
config.module
.rule('fonts')
.test(/.(ttf|otf|eot|woff|woff2)$/)
.use('url-loader')
.loader('url-loader')
.tap(options => {
options = {
// limit: 10000,
name: '/static/fonts/[name].[ext]'
}
return options
})
.end()
externals: {
vue: 'Vue',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
vuex: 'Vuex',
axios: 'axios',
echarts: 'echarts'
}
},
devServer: {
hot: true,
disableHostCheck: true,
host: process.env.VUE_APP_HOST,
port: process.env.VUE_APP_PORT,
headers: {
'Access-Control-Allow-Origin': '*' // 主应用获取子应用时跨域响应头
}
}
\ No newline at end of file
// proxy: {
// '/api': {
// target: 'http://rop-merchant.test.glsx.com.cn',
//
// changeOrigin: true,
//
// pathRewrite: {
// '^/api': '/'
// }
// },
// },
},
chainWebpack: config => {
config.plugin('html').tap(args => {
// args[0].minify.removeComments = false;
args[0].cdn = cdn
return args
})
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
config.module
.rule('fonts')
.test(/.(ttf|otf|eot|woff|woff2)$/)
.use('url-loader')
.loader('url-loader')
.tap(options => {
options = {
// limit: 10000,
name: '/static/fonts/[name].[ext]'
}
return options
})
.end()
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!