MicroCommunityWeb/public/pages/admin/productSj/productSj.js
2024-05-25 14:10:10 +08:00

121 lines
4.5 KiB
JavaScript

/**
入驻小区
**/
(function (vc) {
var DEFAULT_PAGE = 1;
var DEFAULT_ROWS = 10;
vc.extends({
data: {
productSjInfo: {
products: [],
total: 0,
records: 1,
moreCondition: false,
productId: '',
componentShow: 'productSj',
conditions: {
categoryId: '',
state: '2002',
prodName: '',
keyword: '',
barCode: '',
createTime: '',
mallApiCode:'queryAdminProductBmoImpl'
// shopId: vc.getCurrentCommunity().shopId
},
productCategorys:[]
}
},
_initMethod: function () {
$that._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
$that._initservSjtmentTimeInfo();
},
_initEvent: function () {
vc.on('productSj', 'listProduct', function (_param) {
$that.productSjInfo.componentShow = 'productSj';
$that._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
});
vc.on('pagination', 'page_event', function (_currentPage) {
$that._listProducts(_currentPage, DEFAULT_ROWS);
});
},
methods: {
_listProducts: function (_page, _rows) {
$that.productSjInfo.conditions.page = _page;
$that.productSjInfo.conditions.row = _rows;
let param = {
params: $that.productSjInfo.conditions
};
//发送get请求
vc.http.apiGet('/mall.getAdminMallOpenApi',
param,
function (json, res) {
let _json = JSON.parse(json);
$that.productSjInfo.total = _json.total;
$that.productSjInfo.records = _json.records;
$that.productSjInfo.products = _json.data;
vc.emit('pagination', 'init', {
total: $that.productSjInfo.records,
dataCount: $that.productSjInfo.total,
currentPage: _page
});
}, function (errInfo, error) {
console.log('请求失败处理');
}
);
},
_initservSjtmentTimeInfo: function () {
$('.productSjtmentTime').datetimepicker({
language: 'zh-CN',
fontAwesome: 'fa',
format: 'yyyy-mm-dd hh:ii:ss',
initTime: true,
initialDate: new Date(),
autoClose: 1,
todayBtn: true
});
$('.productSjtmentTime').datetimepicker()
.on('changeDate', function (ev) {
var value = $(".productSjtmentTime").val();
$that.productSjInfo.conditions.createTime = value;
});
},
_listProductsToDay: function(){
$that.productSjInfo.conditions.createTime = vc.dateTimeFormat(new Date().getTime());
$that._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
},
_listProductsAll: function(){
$that.productSjInfo.conditions.createTime = '';
$that._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
},
_openAddProductModal: function () {
//vc.emit('addProduct', 'openAddProductModal', {});
$that.productSjInfo.componentShow = 'addProduct';
},
_openEditProductModel: function (_product) {
$that.productSjInfo.componentShow = 'editProduct';
vc.emit('editProduct', 'openEditProductModal', _product);
},
_openDeleteProductModel: function (_product) {
vc.emit('deleteProduct', 'openDeleteProductModal', _product);
},
_queryProductMethod: function () {
$that._listProducts(DEFAULT_PAGE, DEFAULT_ROWS);
},
_moreCondition: function () {
if ($that.productSjInfo.moreCondition) {
$that.productSjInfo.moreCondition = false;
} else {
$that.productSjInfo.moreCondition = true;
}
}
}
});
})(window.vc);