$(function () {
$("#jqGrid").jqGrid({
url: baseURL + 'wjxy/expert/page',
datatype: "json",
colModel: [
{ label: 'id', name: 'id', index: 'id', width: 50, key: true ,hidden: true},
{ label: '行家名称', name: 'name', index: 'name', width: 80 },
{ label: '电话', name: 'phone', index: 'phone', width: 80 },
{ label: '职称', name: 'jobTitle', index: 'job_title', width: 80 },
{ label: '行家头像', name: 'expertPhoto', index: 'expert_photo', width: 80, formatter: imageFormat },
{ label: '所属地区', name: 'expertRegion', index: 'expert_region', width: 80, formatter: function (cellvalue, options, rowdata) {
return '湖北省' + rowdata.cityStr
} },
{ label: '状态', name: 'status', index: 'status', width: 80,formatter: function (cellvalue, options, rowdata) {
if(cellvalue == 0) {
return '禁用'
}else {
return '正常'
}
} },
{ label: '创建时间', name: 'createTime', index: 'create_time', width: 80 },
{ label: '关联用户', name: 'updateId', index: 'update_id', width: 80, formatter: function (cellvalue, options, rowdata) {
return "
" + rowdata.vipName +"
" + "" + rowdata.cardNo + "
"
}
},
],
viewrecords: true,
height: 385,
rowNum: 10,
rowList : [10,30,50],
rownumbers: true,
rownumWidth: 25,
autowidth:true,
multiselect: true,
pager: "#jqGridPager",
jsonReader : {
root: "page.list",
page: "page.currPage",
total: "page.totalPage",
records: "page.totalCount"
},
prmNames : {
page:"page",
rows:"limit",
order: "order"
},
gridComplete:function(){
//隐藏grid底部滚动条
$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
}
});
/* 获取省市区 */
$.ajax({
type: "POST",
url: baseURL + "/api/region/list",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm.location.city = r.data;
}else{
layer.alert("读取省失败");
}
}
});
upload(1,'images','images/*');
});
var vm = new Vue({
el:'#rrapp',
data:{
showList: true,
title: null,
wjxyExpert: {
goodLabels: ''
},
goodLabels: [],
userObj: {},
location: {
province: {},
city: {},
area: {}
},
shopList: [],
labelList: [],
blank: true,
queryParam: {
name: null,
phone:null
}
},
methods: {
query: function () {
vm.reload(1);
},
init() {
vm.queryParam.name = null
vm.queryParam.phone = null
},
reset: function () {
vm.init();
vm.reload(1);
},
add: function(){
vm.showList = false;
vm.title = "新增";
// vm.wjxyExpert = {};
vm.wjxyExpert.memberId = '';
vm.wjxyExpert.status = '';
vm.wjxyExpert.expertPhoto = '';
vm.wjxyExpert.province = 420000;
vm.wjxyExpert.city = '';
vm.wjxyExpert.area = '';
vm.wjxyExpert.name = '';
vm.wjxyExpert.phone = '';
vm.wjxyExpert.jobTitle = '';
vm.wjxyExpert.id = null
clearImg();
vm.userObj = {}
vm.shopList = []
vm.wjxyExpert.jobTitle = '';
vm.location.area = {};
vm.wjxyExpert.goodLabels = ''
vm.goodLabels = []
vm.wjxyExpert.storeIdList = []
vm.wjxyExpert.isHomeRecommend = ''
vm.wjxyExpert.expertReadme = ''
vm.getLabel()
},
update: function (event) {
var id = getSelectedRow();
if(id == null){
return ;
}
vm.showList = false;
vm.blank = true
vm.title = "修改";
vm.getInfo(id)
},
city: function (event) {
var d = event.target.value;
vm.location.area = {};
vm.wjxyExpert.area = '';
// vm.location.city
for (let i=0; i<=vm.location.city.length; i++) {
if(d == vm.location.city[i].id) {
return vm.location.area = vm.location.city[i].childRegionList
}
}
},
getVal:function(val) {
if (val!= "") {
console.log(val);
vm.wjxyExpert.memberId = val
vm.userInfo(val)
}
},
getShop(val) {
if (val!= "") {
console.log(val);
vm.wjxyExpert.storeIdList = val
// var ids = val.join()bvvbbbvbvbv
$.ajax({
type: "POST",
url: baseURL + 'wjxy/store/getByIdList',
contentType: "application/json",
data: JSON.stringify(val),
success: function(r){
if(r.code === 0){
console.log(r)
vm.shopList = r.list
}else{
layer.alert(r.msg);
}
}
});
console.log(val);
// vm.wjxyExpert.memberId = val
// vm.userInfo(val)
}
},
getLabel() {
$.ajax({
type: "GET",
url: baseURL + 'sys/bizlibrary/infoList/maven_label',
contentType: "application/x-www-form-urlencoded",
success: function(r){
if(r.code === 0){
console.log(r)
vm.labelList = r.dictList
// if(Array.isArray(vm.wjxyExpert.labelIdList)) {
// vm.wjxyExpert.labelIdList = vm.wjxyExpert.labelIdList.join()
// }
// if(vm.wjxyExpert.goodLabels) {
// vm.wjxyExpert.goodLabels = vm.wjxyExpert.goodLabels.split(',')
// }
}else{
layer.alert(r.msg);
}
}
});
},
// 关联用户
checkUser() {
var width = ($(window).width() * 0.6);
var height = ($(window).height() -50);
layui.use([ 'layer', 'form'],function() {
var $ = layui.jquery, layer = layui.layer;
layer.open({
type: 2,
area: [width + 'px', height + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
resize:false,
full:true,
shade: 0.4,
title: '选择用户',
anim: 3,
content: 'checkuser.html',
end : function(){
// vm.reload();
// console.log(11)
}
});
})
},
// 选择门店
checkShop() {
var width = ($(window).width() * 0.6);
var height = ($(window).height() -50);
layui.use([ 'layer', 'form'],function() {
var $ = layui.jquery, layer = layui.layer;
layer.open({
type: 2,
area: [width + 'px', height + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
resize:false,
full:true,
shade: 0.4,
title: '选择门店',
anim: 3,
content: 'checkShop.html',
end : function(){
// vm.reload();
// console.log(11)
}
});
})
},
saveOrUpdate: function (event) {
/*图片*/
if ($('#imgUrl1').val() != ''){
vm.wjxyExpert.expertPhoto = $('#imgUrl1').val();
}
console.log(vm.labelList)
console.log(vm.wjxyExpert.goodLabels)
console.log(vm.goodLabels)
if (vm.wjxyExpert.name == '') {
layer.msg('[名称]不能为空',{icon:5})
return false;
}
if (vm.wjxyExpert.phone == '') {
layer.msg('[电话]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.jobTitle == '') {
layer.msg('[职称]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.memberId == '') {
layer.msg('[关联用户]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.status == '') {
layer.msg('[状态]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.city == '') {
layer.msg('[市级]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.area == '') {
layer.msg('[区级]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.storeIdList.length == 0) {
layer.msg('[支持门店]不能为空',{icon:5});
return false;
}
if (vm.goodLabels.length == 0) {
layer.msg('[擅长标签]不能为空',{icon:5});
return false;
}
if (vm.wjxyExpert.expertReadme == '') {
layer.msg('[行家自述]不能为空',{icon:5});
return false;
}
console.log(vm.wjxyExpert.isHomeRecommend,'vm.wjxyExpert.isHomeRecommend')
if (vm.wjxyExpert.isHomeRecommend === '') {
layer.msg('[首页推荐]不能为空',{icon:5});
return false;
}
if(Array.isArray(vm.goodLabels)) {
vm.wjxyExpert.goodLabels = vm.goodLabels.join()
}
vm.wjxyExpert.province = 420000
var url = vm.wjxyExpert.id == null ? "wjxy/expert/save" : "wjxy/expert/update";
var type = vm.wjxyExpert.id == null ? "POST" : "PUT";
$.ajax({
type: type,
url: baseURL + url,
contentType: "application/json",
data: JSON.stringify(vm.wjxyExpert),
success: function(r){
if(r.code === 0){
layer.msg("操作成功", {icon: 1});
vm.reload();
$('#btnSaveOrUpdate').button('reset');
$('#btnSaveOrUpdate').dequeue();
}else{
layer.alert(r.msg);
// $('#btnSaveOrUpdate').button('reset');
// $('#btnSaveOrUpdate').dequeue();
}
}
});
$('#btnSaveOrUpdate').button('loading').delay(1000).queue(function() {
});
},
del: function (event) {
var ids = getSelectedRows();
if(ids == null){
return ;
}
var lock = false;
layer.confirm('确定要删除选中的记录?', {
btn: ['确定','取消'] //按钮
}, function(){
if(!lock) {
lock = true;
$.ajax({
type: "DELETE",
url: baseURL + "wjxy/expert/delete",
contentType: "application/json",
data: JSON.stringify(ids),
success: function(r){
if(r.code == 0){
layer.msg("操作成功", {icon: 1});
$("#jqGrid").trigger("reloadGrid");
}else{
layer.alert(r.msg);
}
}
});
}
}, function(){
});
},
msgh() {
var id = getSelectedRow();
if(id == null){
return ;
}
vm.blank = false;
vm2.blank = true;
vm2.workStu.expertId = id
vm2.parent = id
vm2.reload(1);
console.log(vm2.workStu.expertId)
},
getInfo: function(id){
$.get(baseURL + "wjxy/expert/info/"+id, function(r){
vm.getLabel()
vm.wjxyExpert = r.expert;
console.log(vm.wjxyExpert.area)
vm.wjxyExpert.province = 420000
vm.shopList = vm.wjxyExpert.storeList
vm.goodLabels = vm.wjxyExpert.goodLabels.split(',')
console.log(vm.wjxyExpert.goodLabels)
let ids = []
for(let value of r.expert.storeList) {
ids.push(value.id)
}
vm.wjxyExpert.storeIdList = ids
/*图片*/
if (vm.wjxyExpert.expertPhoto) {
$('#demo1').show();
$('#demo1').attr('src',vm.wjxyExpert.expertPhoto);
}
vm.userInfo(vm.wjxyExpert.memberId)
vm.location.area = [];
// vm.location.city
for (let i=0; i<=vm.location.city.length; i++) {
if(vm.wjxyExpert.city == vm.location.city[i].id) {
return vm.location.area = vm.location.city[i].childRegionList
}
}
// vm.city(vm.wjxyExpert.city)
// vm.getShop()
// console.log(vm.wjxyExpert.storeList)
});
},
userInfo(id) {
$.get(baseURL + "qmgj/memberinfo/info/"+id, function(r){
// vm.wjxyExpert = r.wjxyExpert;
console.log(r)
vm.userObj = r.memberInfo
});
},
reload: function (event) {
vm.showList = true;
var page;
if (event == 1){
page = 1;
} else {
page = $("#jqGrid").jqGrid('getGridParam','page');
}
// vm.queryParam.name = null
// vm.queryParam.phone = null
$("#jqGrid").jqGrid('setGridParam',{
postData: {name: vm.queryParam.name, phone: vm.queryParam.phone},
page:page
}).trigger("reloadGrid");
}
}
});
/*------------------------------------*/
$(function () {
$("#jqGrid2").jqGrid({
url: baseURL + 'wjxy/experttopic/page',
postData: {expertId: vm2.parent},
datatype: "json",
colModel: [
{ label: 'id', name: 'id', index: 'id', width: 50, key: true, hidden: true },
{ label: '话题名称', name: 'topicName', width: 80, sortable:false },
{ label: '话题描述', name: 'topicDescribe', width: 80 , sortable:false },
{ label: '话题价格', name: 'topicPrice', width: 80, sortable:false },
{ label: '状态', name: 'status', width: 80, sortable:false,formatter: function(value, options, row){
if(value == 1) {
return '正常'
}else {
return '禁用'
}
} },
{ label: '创建时间', name: 'createTime', width: 80, sortable:false },
// { label: '数据来源', name: 'fromTo', width: 80, sortable:false , formatter: function(value, options, row){
// if (value == '1') {
// return '小程序';
// } else if (value == '0'){
// return '手动输入';
// } else {
// return '来源不明';
// }
// }
// }
],
viewrecords: true,
width: w,
height: h,
rowNum: 10,
rowList : [10,30,50],
rownumbers: true,
rownumWidth: 25,
autowidth:false,
multiselect: true,
pager: "#jqGridPager2",
jsonReader : {
root: "page.list",
page: "page.currPage",
total: "page.totalPage",
records: "page.totalCount"
},
prmNames : {
page:"page",
rows:"limit",
order: "order"
},
gridComplete:function(){
//隐藏grid底部滚动条
$("#jqGrid2").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
},
loadComplete:function(data){
vm2.jpgrid = data.page.list;
}
});
$.ajax({
type: "POST",
url: baseURL + "sys/bizlibrary/infoList/workStuEnroll",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm2.dict.workStuEnroll = r.dictList;
}else{
layer.alert("读取字典项失败");
}
}
});
$.ajax({
type: "POST",
url: baseURL + "sys/bizlibrary/infoList/workStuNotice",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm2.dict.workStuNotice = r.dictList;
}else{
layer.alert("读取字典项失败");
}
}
});
$.ajax({
type: "POST",
url: baseURL + "sys/bizlibrary/infoList/workStuSignUp",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm2.dict.workStuSignUp = r.dictList;
}else{
layer.alert("读取字典项失败");
}
}
});
$.ajax({
type: "POST",
url: baseURL + "sys/bizlibrary/infoList/workStuPay",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm2.dict.workStuPay = r.dictList;
}else{
layer.alert("读取字典项失败");
}
}
});
$.ajax({
type: "POST",
url: baseURL + "sys/bizlibrary/infoList/gender",
contentType: "application/json",
success: function(r){
if(r.code == 0){
vm2.dict.gender = r.dictList;
}else{
layer.alert("读取字典项失败");
}
}
});
});
var vm2 = new Vue({
el:'#rrapp2',
data:{
jpgrid: {},
blank: false,
showList: true,
title: null,
workStu: {
topicPrice: '',
status: ''
},
showInfo: false,
parent: null,
dict:{
workStuEnroll: null,
workStuNotice: null,
workStuSignUp: null,
workStuPay: null,
gender: null
},
queryParam: {
topicName: null
}
},
methods: {
init: function () {
vm2.queryParam.topicName = null;
},
query: function () {
vm2.reload(1);
},
reset: function () {
vm2.init();
vm2.reload(1);
},
add: function(){
vm2.showList = false;
vm2.title = "新增";
vm2.showInfo = false;
vm2.workStu.topicPrice = '';
vm2.workStu.id = null;
vm2.workStu.status = '';
vm2.workStu.topicName = '';
vm2.workStu.topicDescribe = '';
},
update: function (event) {
var id = getSelectedRowMore(2);
if(id == null){
return ;
}
vm2.showList = false;
vm2.title = "编辑";
vm2.showInfo = false;
vm2.getInfo(id)
},
saveOrUpdate: function (event) {
},
del: function (event) {
var ids = getSelectedRowsMore(2);
if(ids == null){
return ;
}
var lock = false;
layer.confirm('确定要删除选中的记录?', {
btn: ['确定','取消'] //按钮
}, function(){
if(!lock) {
lock = true;
$.ajax({
type: "DELETE",
url: baseURL + "wjxy/experttopic/delete",
contentType: "application/json",
data: JSON.stringify(ids),
success: function(r){
if(r.code == 0){
layer.msg("操作成功", {icon: 1});
vm2.reload(1);
}else{
layer.alert(r.msg);
}
}
});
}
}, function(){
});
},
getInfo: function(id){
$.get(baseURL + "wjxy/experttopic/info/"+id, function(r){
vm2.workStu = r.expertTopic;
});
},
reload: function (event) {
vm2.showInfo = false;
vm2.workStu.sex = '';
vm2.workStu.status = '';
vm2.workStu.notifyStatus = '';
vm2.workStu.signStatus = '';
vm2.workStu.cashStatus = '';
vm2.showList = true;
var page;
if (event == 1){
page = 1;
} else {
page = $("#jqGrid2").jqGrid('getGridParam','page');
}
$("#jqGrid2").jqGrid('setGridParam',{
postData: {expertId: vm2.parent, topicName: vm2.queryParam.topicName},
page:page
}).trigger("reloadGrid");
},
reloadFirst: function (event) {
var page = 1;
vm2.init();
$("#jqGrid2").jqGrid('setGridParam',{
postData:{pid: vm2.parent, queryParam: vm2.queryParam.input},
page:page,
gridComplete:function(){
//隐藏grid底部滚动条
$("#jqGrid2").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
//刷新
vm.blank = false;
vm2.blank = true;
vm2.showList = true;
vm2.showInfo = false;
}
}).trigger("reloadGrid");
},
back: function (event) {
vm.reload();
vm.blank = true;
vm.showList = true;
vm2.blank = false;
},
flow: function () {
var id = getSelectedRowMore(2);
if(id == null){
return ;
}
var width = ($(window).width() * 0.8);
var height = ($(window).height() * 0.8);
layui.use([ 'layer', 'form'],function() {
var $ = layui.jquery, layer = layui.layer;
layer.open({
type: 2,
area: [width + 'px', height + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
resize:false,
full:true,
shade: 0.4,
title: '兼职流程信息',
anim: 3,
content: 'workstu_flow.html?id='+id,
end : function(){
vm2.reload();
}
});
})
},
sign: function () {
var id = getSelectedRowMore(2);
if(id == null){
return ;
}
var width = ($(window).width() * 0.8);
var height = ($(window).height() * 0.8);
layui.use([ 'layer', 'form'],function() {
var $ = layui.jquery, layer = layui.layer;
layer.open({
type: 2,
area: [width + 'px', height + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
resize:false,
full:true,
shade: 0.4,
title: '签到信息明细',
anim: 3,
content: 'worksign.html?id='+id
});
})
},
bill: function () {
var id = getSelectedRowMore(2);
if(id == null){
return ;
}
var width = ($(window).width() * 0.8);
var height = ($(window).height() * 0.8);
layui.use([ 'layer', 'form'],function() {
var $ = layui.jquery, layer = layui.layer;
layer.open({
type: 2,
area: [width + 'px', height + 'px'],
fix: false, //不固定
maxmin: true,
shadeClose: true,
resize:false,
full:true,
shade: 0.4,
title: '工资发放明细',
anim: 3,
content: 'workstu_bill.html?id='+id
});
})
},
exp: function () {
window.location.href = baseURL + "qmgj/workstu/export/"+vm2.parent;
},
qrcode: function () {
window.location.href = baseURL + "qmgj/workstu/qrcode/"+vm2.parent;
},
topicSubmit() {
if (vm2.workStu.topicPrice == '') {
layer.msg('[话题价格]不能为空',{icon:5});
return false;
}
if (vm2.workStu.status == '') {
layer.msg('[状态]不能为空',{icon:5});
return false;
}
var url = vm2.workStu.id == null ? "wjxy/experttopic/save" : "wjxy/experttopic/update";
var type = vm2.workStu.id == null ? "POST" : "PUT";
$.ajax({
type: type,
url: baseURL + url,
contentType: "application/json",
data: JSON.stringify(vm2.workStu),
success: function(r){
if(r.code === 0){
layer.msg("操作成功", {icon: 1});
vm2.reload();
}else{
layer.alert(r.msg);
}
}
});
}
}
});
// layui.use([ 'layer', 'form'],function() {
// var $ = layui.jquery, layer = layui.layer, form = layui.form;
// if (vm2.workStu.topicPrice == '') {
// layer.msg('[话题价格]不能为空',{icon:5});
// return false;
// }
// if (vm2.workStu.status == '') {
// layer.msg('[状态]不能为空',{icon:5});
// return false;
// }
// console.log(vm2.workStu.topicPrice,'111')
// console.log(vm2.workStu.status,'222')
// form.on('submit(go2)', function(data){
// console.log(vm2.workStu.expertId)
// var url = vm2.workStu.id == null ? "wjxy/experttopic/save" : "wjxy/experttopic/update";
// var type = vm2.workStu.id == null ? "POST" : "PUT";
// $.ajax({
// type: type,
// url: baseURL + url,
// contentType: "application/json",
// data: JSON.stringify(vm2.workStu),
// success: function(r){
// if(r.code === 0){
// layer.msg("操作成功", {icon: 1});
// vm2.reload();
// }else{
// layer.alert(r.msg);
// }
// }
// });
// return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
// });
// })