This commit is contained in:
浅念
2025-06-20 17:05:56 +08:00
parent b2a1d5e84e
commit 1374d1938a
23 changed files with 2248 additions and 180 deletions
+247
View File
@@ -0,0 +1,247 @@
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;
// 获取当前语言
var currentLang = localStorage.getItem('language') || 'zh';
var lang = langConfig[currentLang];
var operationBar = $('#currentTableBar').html();
if (operationBar) {
var newHtml = operationBar
.replace(/编辑/g, lang.carlist.operations.edit)
.replace(/删除/g, lang.carlist.operations.delete)
$('#currentTableBar').html(newHtml);
}
var toolbarDemo = $('#toolbarDemo').html();
if (toolbarDemo) {
var newHtmlt = toolbarDemo
.replace(/添加/g, lang.userlist.add)
$('#toolbarDemo').html(newHtmlt);
}
var tableInitb = table.render({
elem: '#currentTableId',
url: lang.baseUrl+'console/vehicle/new/attributes/list',
headers: {
Authorization: 'Bearer ' + sessionStorage.tokencar,
lang:localStorage.getItem('language')?localStorage.getItem('language'):"zh"
},
toolbar: '#toolbarDemo',
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
parseData: function(res) { //res 即为原始返回的数据
console.log(res)
return {
"code": 0, //解析接口状态
"msg": 'message', //解析提示文本
"count": res.data.meta.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
cols: [[
{type: "checkbox"},
{field: 'id', title: 'ID', sort: true},
{field: 'attribute_name', title: lang.alllist.name},
{field: 'status',title:lang.alllist.status,
// templet: function(d){
// var img= '<input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">'
// return img;
// },
templet: function (d) {
form.on("switch(status)", function (data) {
let load = layer.load();
let postData = {};
postData.status = data.elem.checked ? 1 : 0;
postData.id = d.id;
postData.name = d.name;
self.brandupdate({
type:'post',
data: postData,
successCallBack: function (result) {
layer.msg(result.message)
layer.close(load);
},
failCallBack: function (result) {
layer.msg(result.message)
layer.closeAll('loading');
tableInitb.reload()
}
})
});
let checked = d['status'] === 1 ? "checked" : "";
return '<input type="checkbox" value="'+d.status+'" lay-filter="status" lay-skin="switch" lay-text="" '+checked+'/>';
}
},
{field: 'created_at',title: lang.alllist.create_time},
{field: 'updated_at',title: lang.alllist.update_time},
{title: lang.alllist.operation, minWidth: 150, toolbar: '#currentTableBar', align: "center"}
]],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function(res, curr, count){
window.i18n.updatePageContent();
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var result = JSON.stringify(data.field);
table.reload('currentTableId', {
page: {
curr: 1
}
, where: {
name: data.field.name,
status: data.field.status,
}
}, 'data');
return false;
});
/**
* toolbar监听事件
*/
table.on('toolbar(currentTableFilter)', function (obj) {
if (obj.event === 'add') { // 监听添加操作
var index = layer.open({
title: lang.userlist.add,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['70%', '80%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/attributeadd.html',
yes: function (index, layero) {
var iframeWindow = window['layui-layer-iframe' + index]
, submitID = 'saveBtn'
, submit = layero.find('iframe').contents().find('#' + submitID);
//监听提交
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
var field = data.field; //获取提交的字段
const result = {};
if(field.input_type=='color'){
result.value = objentries(field,'color_code','value_name','color_code','value_name')
}else{
result.value = objentries1(field,'value_name','value_name')
}
for (const key in field) {
if (!key.includes('[') && !key.includes(']')) {
result[key] = field[key];
}
}
self.attributesadd({
type: 'post',
data: result,
successCallBack: function (res) {
layer.msg(res.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function (res) {
alert(res.message);
}
})
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
} else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data;
layer.alert(JSON.stringify(data));
}
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj)
});
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
var index = layer.open({
title:lang.audit.edit_title,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['70%', '80%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/attributeedit.html?id='+data.id,
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'saveBtn'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
const result = {};
if(field.input_type=='color'){
result.value = objentriesedt(field,'color_code','value_name','idp','color_code','value_name','id')
}else{
result.value = objentriesedt1(field,'value_name','value_name','idp')
}
for (const key in field) {
if (!key.includes('[') && !key.includes(']')) {
result[key] = field[key];
}
}
self.attributesupdate({
type: 'post',
data: result,
successCallBack: function (res) {
layer.msg(res.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function (res) {
alert(res.message);
}
})
// console.log(field)
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}else if (obj.event === 'delete') {
layer.confirm(lang.audit.confirm_delete, function(index) {
self.attributesdelete({
type:'post',
data:{id:data.id},
successCallBack: function(result){
layer.msg(result.message, {
icon: 1,
time: 1000
});
tableInitb.reload()
},
failCallBack: function(result){
alert(result.message);
window.location.reload()
}
})
});
}
});
});
+191
View File
@@ -0,0 +1,191 @@
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;
// 获取当前语言
var currentLang = localStorage.getItem('language') || 'zh';
var lang = langConfig[currentLang];
var operationBar = $('#currentTableBar').html();
if (operationBar) {
var newHtml = operationBar
.replace(/编辑/g, lang.carlist.operations.edit)
.replace(/删除/g, lang.carlist.operations.delete)
$('#currentTableBar').html(newHtml);
}
var toolbarDemo = $('#toolbarDemo').html();
if (toolbarDemo) {
var newHtmlt = toolbarDemo
.replace(/添加/g, lang.userlist.add)
$('#toolbarDemo').html(newHtmlt);
}
var tableInitb = table.render({
elem: '#currentTableId',
url: lang.baseUrl+'console/vehicle/new/categories/list',
headers: {
Authorization: 'Bearer ' + sessionStorage.tokencar,
lang:localStorage.getItem('language')?localStorage.getItem('language'):"zh"
},
toolbar: '#toolbarDemo',
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
parseData: function(res) { //res 即为原始返回的数据
console.log(res)
return {
"code": 0, //解析接口状态
"msg": 'message', //解析提示文本
"count": res.data.meta.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
cols: [[
{type: "checkbox"},
{field: 'id', title: 'ID', sort: true},
{field: 'category_name', title: lang.alllist.name},
{field: 'sort_order', title: lang.alllist.sort},
{field: 'created_at',title: lang.alllist.create_time},
{field: 'updated_at',title: lang.alllist.update_time},
{title: lang.alllist.operation, minWidth: 150, toolbar: '#currentTableBar', align: "center"}
]],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function(res, curr, count){
window.i18n.updatePageContent();
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var result = JSON.stringify(data.field);
table.reload('currentTableId', {
page: {
curr: 1
}
, where: {
category_name: data.field.category_name
}
}, 'data');
return false;
});
/**
* toolbar监听事件
*/
table.on('toolbar(currentTableFilter)', function (obj) {
if (obj.event === 'add') { // 监听添加操作
var index = layer.open({
title: lang.userlist.add,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['70%', '80%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/categoriesadd.html',
yes: function (index, layero) {
var iframeWindow = window['layui-layer-iframe' + index]
, submitID = 'saveBtn'
, submit = layero.find('iframe').contents().find('#' + submitID);
//监听提交
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
var field = data.field; //获取提交的字段
self.categoriesadd({
type: 'post',
data: data.field,
successCallBack: function (result) {
layer.msg(result.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function (result) {
alert(result.message);
}
})
console.log(field)
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
} else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data;
layer.alert(JSON.stringify(data));
}
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj)
});
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
var index = layer.open({
title:lang.audit.edit_title,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['70%', '80%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/categoriesedit.html?id='+data.id,
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'saveBtn'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
self.categoriesupdate({
type:'post',
data:data.field,
successCallBack: function(result){
layer.msg(result.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function(result){
alert(result.message);
}
})
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}else if (obj.event === 'delete') {
layer.confirm(lang.audit.confirm_delete, function(index) {
self.categoriesdelete({
type:'post',
data:{id:data.id},
successCallBack: function(result){
layer.msg(result.message, {
icon: 1,
time: 1000
});
tableInitb.reload()
},
failCallBack: function(result){
alert(result.message);
window.location.reload()
}
})
});
}
});
});
+83 -73
View File
@@ -24,21 +24,24 @@
"type": "Type",
"agreement": "Agreement",
"general": "General Settings",
"dictionary": "Dictionary Settings",
"newcar":"New Car",
"usedcar":"Used Car",
"seo":"SEO",
"email":"Email"
"dictionary": "Dictionary Settings",
"newcar":"New Car",
"usedcar":"Used Car",
"seo":"SEO",
"email":"Email",
"attribute":"Attribute",
"attributes":"Attribute List",
"categories":"Attribute Categories"
},
"homE": {
"welcome": "Welcome to our website",
"more": "Learn more",
"title": "Data Statistics",
"realtime": "Real-time",
"brandCounts": "Number of Brands",
"inOrderCounts": "Orders in Process",
"inTransitCounts": "In Transit",
"vehicleCounts": "Vehicle Count"
"homE": {
"welcome": "Welcome to our website",
"more": "Learn more",
"title": "Data Statistics",
"realtime": "Real-time",
"brandCounts": "Number of Brands",
"inOrderCounts": "Orders in Process",
"inTransitCounts": "In Transit",
"vehicleCounts": "Vehicle Count"
},
"btn": {
"submit": "Submit",
@@ -150,10 +153,10 @@
"audit": {
"all": "All",
"applied": "Reviewed",
"not_applied": "Not Reviewed",
"pass": "Pass",
"refuse": "Refuse",
"desc": "Description",
"not_applied": "Not Reviewed",
"pass": "Pass",
"refuse": "Refuse",
"desc": "Description",
"editcarbtn": "Edit vehicle"
},
"seach": {
@@ -168,65 +171,72 @@
"user": "User Agreement",
"status1": "Active",
"status2": "Disabled"
},
"seo": {
"title": "Page Title",
"description": "Page Description",
"canonical": "",
"og_type": "Website Type",
"og_title": "Share Title",
"og_description": "Share Description",
"og_image": "Share Thumbnail",
"og_url": "Share URL",
"og_site_name": "Site Name",
"page": "Current Page"
},
"brand": {
"name": "Brand Name",
"logo": "Brand Logo",
"logoalt": "Logo Description",
"status": "Status",
"banner": "Banner Image",
"banneralt": "Banner Description",
"desc": "Brand Description",
"thumbnail": "Thumbnail",
"thumbnailalt": "Thumbnail Description",
"detailsimg": "Brand Carousel Images",
"advantage": "Brand Advantages",
"advantage-title": "Advantage Title",
"advantage-desc": "Advantage Description",
"album": "Brand Album",
"is_hot": "Is Hot"
},
"newcar": {
"memo": "Vehicle Description",
"introduce": "Vehicle Introduction",
"desc": "Vehicle Description",
"characteristic": "Vehicle Features",
"video": "Vehicle Video",
"problem": "FAQ",
"imgalt": "Image Description",
"coveralt": "Cover Image Description"
},
"alls": {
"title": "Title",
"title_placeholder": "Please enter title",
"content": "Content",
"content_placeholder": "Please enter content",
"introduce_placeholder": "Please enter introduction",
"image_desc": "Please enter image description",
"problem": "Question",
"answer": "Answer",
"answer_placeholder": "Please enter answer",
"problem_placeholder": "Please enter question",
"yes": "Yes",
"no": "No"
},
"seo": {
"title": "Page Title",
"description": "Page Description",
"canonical": "",
"og_type": "Website Type",
"og_title": "Share Title",
"og_description": "Share Description",
"og_image": "Share Thumbnail",
"og_url": "Share URL",
"og_site_name": "Site Name",
"page": "Current Page"
},
"brand": {
"name": "Brand Name",
"logo": "Brand Logo",
"logoalt": "Logo Description",
"status": "Status",
"banner": "Banner Image",
"banneralt": "Banner Description",
"desc": "Brand Description",
"thumbnail": "Thumbnail",
"thumbnailalt": "Thumbnail Description",
"detailsimg": "Brand Carousel Images",
"advantage": "Brand Advantages",
"advantage-title": "Advantage Title",
"advantage-desc": "Advantage Description",
"album": "Brand Album",
"is_hot": "Is Hot"
},
"newcar": {
"memo": "Vehicle Description",
"introduce": "Vehicle Introduction",
"desc": "Vehicle Description",
"characteristic": "Vehicle Features",
"video": "Vehicle Video",
"problem": "FAQ",
"imgalt": "Image Description",
"coveralt": "Cover Image Description"
},
"sku": {
"name": "Attribute name",
"value": "Attribute value",
"desc": "Attribute"
},
"alls": {
"title": "Title",
"title_placeholder": "Please enter title",
"content": "Content",
"content_placeholder": "Please enter content",
"introduce_placeholder": "Please enter introduction",
"image_desc": "Please enter image description",
"problem": "Question",
"answer": "Answer",
"answer_placeholder": "Please enter answer",
"problem_placeholder": "Please enter question",
"yes": "Yes",
"no": "No"
},
"sort": "Sort",
"pleaseenter": "Please enter",
"Belongingbrand": "Belonging Brand",
"typeimg": "Type Image",
"Imageratio":"Aspect ratio",
"Belongingtype": "Category",
"Images": "Images",
"typeimg": "Type Image",
"Imageratio":"Aspect ratio",
"Imagesize":"Image size",
"select": "Please select",
"logout": "Logout",
+83 -73
View File
@@ -24,21 +24,24 @@
"type": "типами",
"agreement": "соглашениями",
"general": "Общие настройки",
"dictionary": "Настройки словарей",
"newcar":"Новые автомобили",
"usedcar":"Б/у автомобили",
"seo":"SEO",
"email":"Эл. почта"
"dictionary": "Настройки словарей",
"newcar":"Новые автомобили",
"usedcar":"Б/у автомобили",
"seo":"SEO",
"email":"Эл. почта",
"attribute":"Свойства",
"attributes":"Список атрибутов",
"categories":"Категории атрибутов"
},
"home": {
"welcome": "Добро пожаловать на наш сайт",
"more": "Узнать больше",
"title": "Статистика данных",
"realtime": "В реальном времени",
"brandCounts": "Количество брендов",
"inOrderCounts": "Заказы в обработке",
"inTransitCounts": "В пути",
"vehicleCounts": "Количество автомобилей"
"home": {
"welcome": "Добро пожаловать на наш сайт",
"more": "Узнать больше",
"title": "Статистика данных",
"realtime": "В реальном времени",
"brandCounts": "Количество брендов",
"inOrderCounts": "Заказы в обработке",
"inTransitCounts": "В пути",
"vehicleCounts": "Количество автомобилей"
},
"btn": {
"submit": "Отправить",
@@ -150,10 +153,10 @@
"audit": {
"all": "Все",
"applied": "Проверено",
"not_applied": "Не проверено",
"pass": "Пропустить",
"refuse": "Отказать",
"desc": "Описание",
"not_applied": "Не проверено",
"pass": "Пропустить",
"refuse": "Отказать",
"desc": "Описание",
"editcarbtn": "Изменить авто"
},
"seach": {
@@ -168,65 +171,72 @@
"user": "Пользовательское соглашение",
"status1": "Активно",
"status2": "Отключено"
},
"seo": {
"title": "Заголовок страницы",
"description": "Описание страницы",
"canonical": "",
"og_type": "Тип веб-страницы",
"og_title": "Заголовок для публикации",
"og_description": "Описание для публикации",
"og_image": "Миниатюра для публикации",
"og_url": "Ссылка для публикации",
"og_site_name": "Название сайта",
"page": "Текущая страница"
},
"brand": {
"name": "Название бренда",
"logo": "Логотип бренда",
"logoalt": "Описание логотипа",
"status": "Статус",
"banner": "Баннер",
"banneralt": "Описание баннера",
"desc": "Описание бренда",
"thumbnail": "Миниатюра",
"thumbnailalt": "Описание миниатюры",
"detailsimg": "Карусель изображений бренда",
"advantage": "Преимущества бренда",
"advantage-title": "Заголовок преимущества",
"advantage-desc": "Описание преимущества",
"album": "Альбом бренда",
"is_hot": "Популярный"
},
"newcar": {
"memo": "Описание автомобиля",
"introduce": "Описание автомобиля",
"desc": "Описание автомобиля",
"characteristic": "Характеристики автомобиля",
"video": "Видео автомобиля",
"problem": "Частые вопросы",
"imgalt": "Описание изображения",
"coveralt": "Описание обложки"
},
"alls": {
"title": "Заголовок",
"title_placeholder": "Введите заголовок",
"content": "Содержание",
"content_placeholder": "Введите содержание",
"introduce_placeholder": "Введите описание",
"image_desc": "Введите описание изображения",
"problem": "Вопрос",
"answer": "Ответ",
"answer_placeholder": "Введите ответ",
"problem_placeholder": "Введите вопрос",
"yes": "Да",
"no": "Нет"
},
"seo": {
"title": "Заголовок страницы",
"description": "Описание страницы",
"canonical": "",
"og_type": "Тип веб-страницы",
"og_title": "Заголовок для публикации",
"og_description": "Описание для публикации",
"og_image": "Миниатюра для публикации",
"og_url": "Ссылка для публикации",
"og_site_name": "Название сайта",
"page": "Текущая страница"
},
"brand": {
"name": "Название бренда",
"logo": "Логотип бренда",
"logoalt": "Описание логотипа",
"status": "Статус",
"banner": "Баннер",
"banneralt": "Описание баннера",
"desc": "Описание бренда",
"thumbnail": "Миниатюра",
"thumbnailalt": "Описание миниатюры",
"detailsimg": "Карусель изображений бренда",
"advantage": "Преимущества бренда",
"advantage-title": "Заголовок преимущества",
"advantage-desc": "Описание преимущества",
"album": "Альбом бренда",
"is_hot": "Популярный"
},
"newcar": {
"memo": "Описание автомобиля",
"introduce": "Описание автомобиля",
"desc": "Описание автомобиля",
"characteristic": "Характеристики автомобиля",
"video": "Видео автомобиля",
"problem": "Частые вопросы",
"imgalt": "Описание изображения",
"coveralt": "Описание обложки"
},
"sku": {
"name": "Название атрибута",
"value": "Значение атрибута",
"desc": "Атрибут"
},
"alls": {
"title": "Заголовок",
"title_placeholder": "Введите заголовок",
"content": "Содержание",
"content_placeholder": "Введите содержание",
"introduce_placeholder": "Введите описание",
"image_desc": "Введите описание изображения",
"problem": "Вопрос",
"answer": "Ответ",
"answer_placeholder": "Введите ответ",
"problem_placeholder": "Введите вопрос",
"yes": "Да",
"no": "Нет"
},
"sort": "Сортировка",
"pleaseenter": "Пожалуйста, введите",
"Belongingbrand": "Принадлежащий бренд",
"typeimg": "Изображение типа",
"Imageratio":"Соотношение сторон",
"Belongingtype": "Категория",
"Images": "Изображения",
"typeimg": "Изображение типа",
"Imageratio":"Соотношение сторон",
"Imagesize":"Размер изображения",
"select": "Пожалуйста, выберите",
"logout": "Выйти",
+11 -1
View File
@@ -28,7 +28,10 @@
"newcar":"新车管理",
"usedcar":"二手车",
"seo":"SEO管理",
"email":"邮箱管理"
"email":"邮箱管理",
"attribute":"属性管理",
"attributes":"属性列表",
"categories":"属性分类"
},
"home": {
"welcome": "欢迎访问我们的网站",
@@ -208,6 +211,11 @@
"imgalt":"图片描述",
"coveralt":"封面图描述"
},
"sku":{
"name":"属性名称",
"value":"属性值",
"desc":"属性"
},
"alls":{
"title": "标题",
"title_placeholder": "请输入标题",
@@ -225,6 +233,8 @@
"sort": "排序",
"pleaseenter":"请输入",
"Belongingbrand":"所属品牌",
"Belongingtype":"所属分类",
"Images":"图片",
"typeimg":"类型图",
"Imageratio":"图片比例",
"Imagesize":"图片尺寸",
+15 -3
View File
@@ -16,10 +16,12 @@ layui.use(['form', 'table'], function () {
.replace(/删除/g, lang.carlist.operations.delete)
.replace(/审核/g, lang.carlist.operations.check)
.replace(/详情/g, lang.carlist.operations.show)
.replace(/属性/g, lang.carlist.operations.sku)
.replace(/Edit/g, lang.carlist.operations.edit)
.replace(/Delete/g, lang.carlist.operations.delete)
.replace(/Check/g, lang.carlist.operations.check)
.replace(/Details/g, lang.carlist.operations.show);
.replace(/Details/g, lang.carlist.operations.show)
.replace(/Sku/g, lang.carlist.operations.sku);
$('#currentTableBar').html(newHtml);
}
var toolbarDemo = $('#toolbarDemo').html();
@@ -156,8 +158,8 @@ layui.use(['form', 'table'], function () {
alert(result.message);
}
})
console.log(datas)
console.log(field)
// console.log(datas)
// console.log(field)
});
submit.trigger('click');
@@ -250,6 +252,16 @@ layui.use(['form', 'table'], function () {
area: ['60%', '85%'],
content: '../page/table/newcarlistshow.html?id='+data.id
});
}else if (obj.event === 'sku') { // 监听删除操作
var index = layer.open({
title: lang.carlist.operations.sku,
type: 2,
shade: 0.2,
maxmin: true,
shadeClose: false,
area: ['80%', '90%'],
content: '../page/sku.html?id='+data.id
});
}
});
+225
View File
@@ -0,0 +1,225 @@
layui.use(['form', 'table'], function () {
var $ = layui.jquery,
form = layui.form,
table = layui.table;
// 获取当前语言
var currentLang = localStorage.getItem('language') || 'zh';
var lang = langConfig[currentLang];
var operationBar = $('#currentTableBar').html();
if (operationBar) {
var newHtml = operationBar
.replace(/编辑/g, lang.carlist.operations.edit)
.replace(/删除/g, lang.carlist.operations.delete)
$('#currentTableBar').html(newHtml);
}
var toolbarDemo = $('#toolbarDemo').html();
if (toolbarDemo) {
var newHtmlt = toolbarDemo
.replace(/添加/g, lang.userlist.add)
$('#toolbarDemo').html(newHtmlt);
}
var tableInitb = table.render({
elem: '#currentTableId',
url: lang.baseUrl+'console/vehicle/new/sku/list?id='+getQueryString('id'),
headers: {
Authorization: 'Bearer ' + sessionStorage.tokencar,
lang:localStorage.getItem('language')?localStorage.getItem('language'):"zh"
},
toolbar: '#toolbarDemo',
defaultToolbar: ['filter', 'exports', 'print', {
title: '提示',
layEvent: 'LAYTABLE_TIPS',
icon: 'layui-icon-tips'
}],
parseData: function(res) { //res 即为原始返回的数据
console.log(res)
return {
"code": 0, //解析接口状态
"msg": 'message', //解析提示文本
"count": res.data.meta.total, //解析数据长度
"data": res.data.list //解析数据列表
};
},
cols: [[
{type: "checkbox"},
{field: 'id', title: 'ID', sort: true},
{field: 'name', title: lang.alllist.name},
{field: 'status',title:lang.alllist.status,
// templet: function(d){
// var img= '<input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">'
// return img;
// },
templet: function (d) {
form.on("switch(status)", function (data) {
let load = layer.load();
let postData = {};
postData.status = data.elem.checked ? 1 : 0;
postData.id = d.id;
postData.name = d.name;
self.brandupdate({
type:'post',
data: postData,
successCallBack: function (result) {
layer.msg(result.message)
layer.close(load);
},
failCallBack: function (result) {
layer.msg(result.message)
layer.closeAll('loading');
tableInitb.reload()
}
})
});
let checked = d['status'] === 1 ? "checked" : "";
return '<input type="checkbox" value="'+d.status+'" lay-filter="status" lay-skin="switch" lay-text="" '+checked+'/>';
}
},
{title: lang.alllist.operation, minWidth: 150, toolbar: '#currentTableBar', align: "center"}
]],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function(res, curr, count){
window.i18n.updatePageContent();
}
});
// 监听搜索操作
form.on('submit(data-search-btn)', function (data) {
var result = JSON.stringify(data.field);
table.reload('currentTableId', {
page: {
curr: 1
}
, where: {
name: data.field.name,
status: data.field.status,
}
}, 'data');
return false;
});
/**
* toolbar监听事件
*/
table.on('toolbar(currentTableFilter)', function (obj) {
if (obj.event === 'add') { // 监听添加操作
var index = layer.open({
title: 'SKU '+lang.userlist.add,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['80%', '90%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/skuadd.html?vehicle_id='+getQueryString('id'),
yes: function (index, layero) {
var iframeWindow = window['layui-layer-iframe' + index]
, submitID = 'saveBtn'
, submit = layero.find('iframe').contents().find('#' + submitID);
//监听提交
iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
var field = data.field; //获取提交的字段
const result = regroupIndexedFields(field,'skuAttributes');
self.skuadd({
type: 'post',
data: result,
successCallBack: function (result) {
layer.msg(result.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function (result) {
alert(result.message);
}
})
// console.log(result);
// console.log(field)
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
} else if (obj.event === 'delete') { // 监听删除操作
var checkStatus = table.checkStatus('currentTableId')
, data = checkStatus.data;
layer.alert(JSON.stringify(data));
}
});
//监听表格复选框选择
table.on('checkbox(currentTableFilter)', function (obj) {
console.log(obj)
});
table.on('tool(currentTableFilter)', function (obj) {
var data = obj.data;
if (obj.event === 'edit') {
var index = layer.open({
title:'SKU '+lang.audit.edit_title,
type: 2,
shade: 0.2,
maxmin:true,
shadeClose: true,
area: ['80%', '90%'],
btn: [lang.audit.confirm, lang.audit.cancel],
content: '../page/table/skuedit.html?id='+data.id+'&vehicle_id='+getQueryString('id'),
yes: function(index, layero){
var iframeWindow = window['layui-layer-iframe'+ index]
,submitID = 'saveBtn'
,submit = layero.find('iframe').contents().find('#'+ submitID);
//监听提交
iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
var field = data.field; //获取提交的字段
const result = regroupIndexedFields(field,'skuAttributes');
// console.log(result)
// console.log(field)
self.skuupdate({
type:'post',
data:result,
successCallBack: function(result){
layer.msg(result.message)
layer.close(index); //关闭弹层
tableInitb.reload()
},
failCallBack: function(result){
alert(result.message);
}
})
});
submit.trigger('click');
}
});
$(window).on("resize", function () {
layer.full(index);
});
return false;
}else if (obj.event === 'delete') {
layer.confirm(lang.audit.confirm_delete, function(index) {
self.skudelete({
type:'post',
data:{id:data.id},
successCallBack: function(result){
layer.msg(result.message, {
icon: 1,
time: 1000
});
tableInitb.reload()
},
failCallBack: function(result){
alert(result.message);
window.location.reload()
}
})
});
}
});
});
+11 -7
View File
@@ -1,8 +1,9 @@
// 多语言配置
// var baseUrl = 'https://server.orzar.shop/'
var baseUrllang = "https://usedcar.server.hnxinyouhe.com/";
var langConfig = {
'zh': {
'baseUrl':"https://server.orzar.shop/",
'baseUrl':baseUrllang,
'select_placeholder': '请选择',
userlist:{
'search_info': '搜索信息',
@@ -60,7 +61,8 @@ var langConfig = {
'edit': '编辑',
'delete': '删除',
'check': '审核',
'show': '详情'
'show': '详情',
'sku':"属性"
}
},
audit:{
@@ -138,7 +140,7 @@ var langConfig = {
}
},
'en': {
'baseUrl':"https://server.orzar.shop/",
'baseUrl':baseUrllang,
'select_placeholder': 'Please Select',
userlist:{
'search_info': 'Search Information',
@@ -196,7 +198,8 @@ var langConfig = {
'edit': 'Edit',
'delete': 'Delete',
'check': 'Check',
'show': 'Details'
'show': 'Details',
'sku':'Attribute'
},
},
audit:{
@@ -262,7 +265,7 @@ var langConfig = {
}
},
'ru':{
"baseUrl": "https://server.orzar.shop/",
"baseUrl": baseUrllang,
"select_placeholder": "Выберите",
"userlist": {
"search_info": "Поиск информации",
@@ -320,7 +323,8 @@ var langConfig = {
"edit": "Редактировать",
"delete": "Удалить",
"check": "Проверить",
"show": "Подробности"
"show": "Подробности",
'sku':'Свойства'
}
},
"audit": {