Files
im/plugin/admin/public/js/product.js
T

132 lines
5.0 KiB
JavaScript
Raw Normal View History

2025-11-07 09:56:20 +08:00
define(['table', 'upload','form'], function (Table,Upload,Form) {
var product = {
//Do setup work hereAction
index: function () {
window.statuskOption= Config.statusList;
Table.api.init({
extend: {
2025-12-24 16:59:05 +08:00
index_url: 'product/select',
add_url: 'product/insert',
edit_url: 'product/update',
del_url: 'product/delete',
multi_url: 'product/multi',
//dragsort_url: 'product/weigh',
2025-11-07 09:56:20 +08:00
table: 'product',
}
});
var table = $("#table");
var tableOptions = {
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
commonSearch: false,
search: false,
columns: [
[
{checkbox: true},
{
field: 'id',
title: 'ID',
filter: "number",
sortable: true // 是否排序
},
{
title: "名称",
field: "title",
filter: "string",
},
{
title: "单价",
field: "price",
filter: "string",
formatter:Table.api.formatter.number
},
{
title: "收益",
field: "score",
filter: "number",
formatter:function(v,row){
return row['min_score']+'~'+row['max_score']+'积分';
}
},
{
title: "总量",
field: "total",
filter: "number",
formatter:function(v){
return v+'个';
}
},
{
title: "每日",
field: "assign_count",
filter: "number",
formatter:function(v){
return v+'份';
}
},
{
title: "销量",
field: "sales",
filter: "number",
formatter:function(v){
return v+'份';
},
visible:false
},
{
title: "状态",
field: "status",
sortable: true,
formatter:Table.api.formatter.status,
searchList:window.statuskOption,
operate:false,
filter: "select",
filterOption:"statuskOption"
},
{
title: "memo",
field: "memo",
visible: false,
},
{
title: "创建时间",
field: "created_at",
visible: false,
},
{
title: "更新时间",
field: "updated_at",
visible: false,
},
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
};
// 初始化表格
table.bootstrapTable(tableOptions);
// 为表格绑定事件
Table.api.bindevent(table);
},
update:function(){
this.bindevent();
},
insert:function(){
this.bindevent();
},
bindevent:function(){
2025-12-24 16:59:05 +08:00
Config['upload_url'] = 'files/upload';
2025-11-07 09:56:20 +08:00
var form = $('form');
var that = this;
$('[name=cycle_type]').on('change',function(){
console.log($(this).val());
$('[name=cycle_type]').val($(this).val());
//$('#random_build_btn').parent().parent().find('input').val(that.generatepassword(48));
});
Form.api.bindevent(form)
}
};
return product
});