define(['jquery', 'bootstrap', 'backend', 'table', 'form','vue'], function ($, undefined, Backend, Table, Form, Vue) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { dragsort_url: '', index_url: 'service/shop/goods/index' + location.search, add_url: 'service/shop/goods/add', edit_url: 'service/shop/goods/edit', multi_url: 'service/shop/goods/multi', import_url: 'service/shop/goods/import', table: 'service_goods', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'updatetime', fixedColumns: true, fixedRightNumber: 1, columns: [ [ {field: 'id', title: __('商品信息'),operate: false,cellStyle: function () {return {css: {"min-width": "200px"}}},formatter:function (value,row){ let result = `
${row.name}
`; if(row.status == 'normal'){ result += `
已上架
` }else { result += `
已下架
` } result += `
¥${row.price}
ID:${row.id}
${row.tag_name}
${row.categoryName}/${row.twoCategoryName}
${row.to_shop_text}
销量:${row.salenums}
所属商家:${row.shopname}
` return result }}, {field: 'id', title: __('城市/规格'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){ let result = ''; if(row.city){ result += `
城市 ${row.city}专属
` }else { result += `
城市 全国通用
` } if(row.spec_type == 1){ result += `
规格 ${row.spec_type_text}
` }else { result += `
规格 ${row.spec_type_text}
` } return result }}, {field: 'id', title: __('服务者职能'),operate: false,cellStyle: function () {return {css: {"min-width": "200px","max-width": "300px"}}},formatter:function (value,row){ let word = row.skillCateName.split(',') let result = '
'; for(let i=0; i < word.length; i++){ result += `
${word[i]}
` } result+='
' return result }}, {field: 'id', title: __('时间设置'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){ return `
最早相应 ${row.response_hour}小时
可约时段 ${row.start_hour}点-${row.end_hour}点
` }}, {field: 'id', title: __('下单设置'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){ return `
是否选择出行 ${row.is_travel_text}
是否选择服务人员 ${row.choose_skill_type_text}
` }}, {field: 'id', title: __('状态'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){ let result = `
审核结果 ${row.shop_state_text}
` if(row.shop_state == -1){ result += `
拒绝原因
${row.note}
` } return result }}, {field: 'id', title: __('时间/权重'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){ return `
更新时间 ${row.update_time}
权重 ${row.weigh}
` }}, {checkbox: true,visible: false}, {field: 'id', title: __('Id'),visible: false}, {field: 'name', title: __('Name'), operate: 'LIKE',visible: false}, {field: 'category_id', title: __('Category_id'),visible: false}, {field: 'two_category_id', title: __('Two_category_id'),visible: false}, {field: 'skill_cate_ids', title: __('Skill_cate_ids'), operate: 'LIKE',visible: false}, {field: 'shop_id', title: __('Shop_id'),visible: false}, {field: 'shop_user_id', title: __('Shop_user_id'),visible: false}, {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1')}, formatter: Table.api.formatter.normal,visible: false}, {field: 'to_shop', title: __('To_shop'), searchList: {"door":__('To_shop door'),"shop":__('To_shop shop')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label,visible: false}, {field: 'is_travel', title: __('Is_travel'), searchList: {"0":__('Is_travel 0'),"1":__('Is_travel 1')}, formatter: Table.api.formatter.normal,visible: false}, {field: 'tag_name', title: __('Tag_name'), operate: 'LIKE',visible: false}, {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image,visible: false}, {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images,visible: false}, {field: 'price', title: __('Price'), operate:'BETWEEN',visible: false}, {field: 'cost_seconds', title: __('Cost_seconds'),visible: false}, {field: 'response_hour', title: __('Response_hour'),visible: false}, {field: 'spec_type', title: __('Spec_type'), searchList: {"0":__('Spec_type 0'),"1":__('Spec_type 1')}, formatter: Table.api.formatter.normal,visible: false}, {field: 'choose_skill_type', title: __('Choose_skill_type'), searchList: {"0":__('Choose_skill_type 0'),"1":__('Choose_skill_type 1')}, formatter: Table.api.formatter.normal,visible: false}, {field: 'flow_path_images', title: __('Flow_path_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images,visible: false}, {field: 'illustrate_images', title: __('Illustrate_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images,visible: false}, {field: 'salenums', title: __('Salenums'),visible: false}, {field: 'shop_state', title: __('Shop_state'), searchList: {"0":__('Shop_state 0'),"1":__('Shop_state 1'),"-1":__('Shop_state -1')}, formatter: Table.api.formatter.normal,visible: false}, {field: 'status', title: __('Status'), searchList: {"normal":__('Status normal'),"hidden":__('Status hidden')}, formatter: Table.api.formatter.status,visible: false}, {field: 'note', title: __('Note'), operate: 'LIKE',visible: false}, {field: 'weigh', title: __('Weigh'), operate: false,visible: false}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'agree', text: __('审核通过'), title: __('审核通过'), classname: 'btn btn-xs btn-info btn-ajax btn-restoreit', url: 'service/shop/goods/agree', success: function (data, ret) { $(".btn-refresh").trigger('click'); }, hidden:function(row){ if(row.shop_state !== 0){ return true; } }, }, { name: 'refuse', text: __('审核拒绝'), title: __('审核拒绝'), classname: 'btn btn-xs btn-danger btn-dialog', url: function(row){ return 'service/shop/goods/refuse?ids='+row.id; }, hidden:function(row){ if(row.shop_state !== 0){ return true; } }, }, { name: 'up', title: __('上架'), text: __('上架'), classname: 'btn btn-xs btn-detail btn-ajax', confirm: '确认上架?', url: function(row){ return 'service/goods/updateGoodsStatus?status=normal&id='+row.id; }, success: function (data, ret) { $(".btn-refresh").trigger('click'); }, visible:function(row){ if(row.shop_state == 1 && row.status == 'hidden'){ return true; } } }, { name: 'down', title: __('下架'), text: __('下架'), classname: 'btn btn-xs btn-down btn-ajax', confirm: '确认下架?', url: function(row){ return 'service/goods/updateGoodsStatus?status=hidden&id='+row.id; }, success: function (data, ret) { $(".btn-refresh").trigger('click'); }, error: function (data, ret) { console.log(data, ret); Layer.alert(ret.msg); return false; }, visible:function(row){ if(row.shop_state == 1 && row.status == 'normal'){ return true; } } }, { name: 'list', title: __('附加项目'), text: __('附加项目'), classname: 'btn btn-xs btn-change btn-dialog', url: function(row){ return 'service/goodsadd/index?goods_id='+row.id; }, }, { name: 'edit', text: __('编辑'), title: __('编辑'), classname: 'btn btn-xs btn-status btn-dialog', icon: 'fa fa-list-o', url: 'service/shop/goods/edit', }, { name: 'del', text: __('删除'), title: __('删除'), classname: 'btn btn-xs btn-cancel btn-dialog', icon: 'fa fa-list-o', url: 'service/shop/goods/del', } ],formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, recyclebin: function () { // 初始化表格参数配置 Table.api.init({ extend: { 'dragsort_url': '' } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: 'service/shop/goods/recyclebin' + location.search, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id')}, {field: 'name', title: __('Name'), align: 'left'}, { field: 'deletetime', title: __('Deletetime'), operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime }, { field: 'operate', width: '140px', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'Restore', text: __('Restore'), classname: 'btn btn-xs btn-info btn-ajax btn-restoreit', icon: 'fa fa-rotate-left', url: 'service/shop/goods/restore', refresh: true }, { name: 'Destroy', text: __('Destroy'), classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit', icon: 'fa fa-times', url: 'service/shop/goods/destroy', refresh: true } ], formatter: Table.api.formatter.operate } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, agree: function () { $(document).on('click', '.btn-embossed', function () { parent.$(".btn-refresh").trigger('click'); }); Controller.api.bindevent(); }, refuse: function () { $(document).on('click', '.btn-embossed', function () { parent.$(".btn-refresh").trigger('click'); }); Controller.api.bindevent(); }, add: function () { Controller.api.bindevent(); }, edit: function () { let add = new Vue({ el: '#app', data(){ return { category_id: '', two_category_id: '', spec_type: Config.spec_type, choose_skill_type: Config.choose_skill_type, categoryList: [{name: '测试',id:1}], spu: Config.spec_type === 1 ? Config.spu : [{ name: '', info: [{name: ''}] }], sku: Config.spec_type === 1 ? Config.sku :[], status: Config.status } }, watch:{ spu:{ deep: true, handler(){ let sku = this.combination(this.spu) let arr = []; for(let i = 0; i < sku.length; i++){ arr.push({ name: sku[i].join(','), cost_seconds:'', price: '' }) } this.sku = arr; } }, category_id(){ console.log(111) this.two_category_id = '' } }, methods:{ changeCate(){ console.log(1111) Fast.api.ajax({ url: 'service/goods/category', loading: true, data: { pid: this.category_id } }, function (ret, res) { Fast.api.close(); }) }, changeSpecType(e){ console.log(this.spec_type) }, addSpuName(){ this.spu.push({ name: '', info: [{name: ''}] }) }, delSpuName(index){ this.spu.splice(index,1) }, delSkuName(key, value){ value.splice(key,1) }, addSkuName(value){ value.push({name: ''}) }, combination(spu){ let result = [[]]; spu.map(a=>{ var res = []; result.map(b=>{ a.info.map(c => { res.push([...b,c.name]) }) }) result = res; }) return result } } }) Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });