| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468 |
- 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 = `<div style="display: flex;align-items: center">
- <img src="${row.image}" alt="" style="width: 92px;height: 92px;">
- <div style="flex: 1;margin-left: 20px;">
- <div style="width: 100%;display: flex;align-items: center;justify-content: space-between">
- <div style="color: #333;font-size: 14px;margin-right: 10px;font-weight:bold;">${row.name}</div>`;
-
- if(row.status == 'normal'){
- result += `<div style="background: #FFF7E6;height: 26px;display: flex;align-items: center;padding: 0 8px;border-radius: 13px;color: #FFA600;margin-right: 10px;font-size:12px;">已上架</div>`
- }else {
- result += `<div style="background: #F7F7F7;height: 26px;display: flex;align-items: center;padding: 0 8px;border-radius: 13px;color: #A4A9B7;margin-right: 10px;font-size:12px;">已下架</div>`
- }
- result += `
-
- <div style="flex:1"></div>
- <div style="color: #E4484B;font-size: 14px;">¥${row.price}</div>
- <div style="background: rgba(248, 118, 121, 0.10);height: 26px;display: flex;align-items: center;padding: 0 8px;border-radius: 13px;margin-left: 8px;color:rgba(248, 118, 121, 1);"><span style="color: rgba(248, 118, 121, 1)">ID:</span>${row.id}</div>
- </div>
- <div style="color: #666;font-size: 12px;text-align: left;margin: 10px 0;">${row.tag_name}</div>
- <div style="display: flex;align-items: center;">
- <div style="background: #F0FAF3;height: 26px;display: flex;align-items: center;padding: 0 8px;border-radius: 13px;color: #62CB81;margin-right: 10px;font-size:12px;">${row.categoryName}/${row.twoCategoryName}</div>
- <div style="background: rgba(97, 22, 255, 0.07);height: 26px;display: flex;align-items: center;padding: 0 8px;border-radius: 13px;color: rgba(97, 22, 255, 1);margin-right: 10px;font-size:12px;">${row.to_shop_text}</div>
- <div></div>
- <div style="color: #999;font-size: 12px;">销量:${row.salenums}</div>
- </div>
- <div style="display: flex;align-items: center;margin-top: 8px;width: 100%;">
- <div style="width: 100%;background: #EFF5FF;display: flex;align-items: center;padding: 8px;border-radius: 6px;color: #1677FF;"><span style="color: #999999">所属商家:</span>${row.shopname}</div>
- </div>
- </div>
- </div>`
- return result
- }},
- {field: 'id', title: __('城市/规格'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
- let result = '';
- if(row.city){
- result += `<div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;border-bottom: 1px solid #EEEEEE;">
- <span style="font-size: 14px;color: #999;">城市</span>
- <span style="color: #333333;font-size: 14px;">${row.city}专属</span>
- </div>`
- }else {
- result += `<div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;border-bottom: 1px solid #EEEEEE;">
- <span style="font-size: 14px;color: #999;">城市</span>
- <span style="color: #333333;font-size: 14px;">全国通用</span>
- </div>`
- }
- if(row.spec_type == 1){
- result += `
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">规格</span>
- <span style="color: #6116FF;font-size: 14px;">${row.spec_type_text}</span>
- </div>
- `
- }else {
- result += `
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">规格</span>
- <span style="color: #1677FF;font-size: 14px;">${row.spec_type_text}</span>
- </div>
- `
- }
- 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 = '<div style="color: #333;font-size: 14px;margin-bottom: 8px;flex-wrap: wrap;display: flex;align-items: center">';
- for(let i=0; i < word.length; i++){
- result += `<div style="margin: 0 8px 8px;">${word[i]}</div>`
- }
- result+='</div>'
- return result
- }},
- {field: 'id', title: __('时间设置'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
- return `
-
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;border-bottom: 1px solid #EEEEEE;">
- <span style="font-size: 14px;color: #999;">最早相应</span>
- <span style="color: #333;font-size: 14px;">${row.response_hour}小时</span>
- </div>
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">可约时段</span>
- <span style="color: #FF1F2B;font-size: 14px;">${row.start_hour}点-${row.end_hour}点</span>
- </div>
- `
- }},
- {field: 'id', title: __('下单设置'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
- return `
-
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;border-bottom: 1px solid #EEEEEE;">
- <span style="font-size: 14px;color: #999;">是否选择出行</span>
- <span style="color: #62CB81;font-size: 14px;">${row.is_travel_text}</span>
- </div>
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">是否选择服务人员</span>
- <span style="color: #333;font-size: 14px;">${row.choose_skill_type_text}</span>
- </div>
- `
- }},
- {field: 'id', title: __('状态'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
- let result = ` <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">审核结果</span>
- <span style="color: #62CB81;font-size: 14px;">${row.shop_state_text}</span>
- </div>`
- if(row.shop_state == -1){
- result += `
- <div style="display: flex;align-items: flex-start;justify-content:space-between;width: 250px;height: 66px;white-space:normal;padding:20px 20px 0;border-top: 1px solid #EEEEEE;">
- <div style="font-size: 14px;color: #999;flex-shrink:0;">拒绝原因</div>
- <div style="color: #FF1F2B;font-size: 14px;text-align:left;margin-left:20px">${row.note}</div>
- </div>`
- }
- return result
-
- }},
- {field: 'id', title: __('时间/权重'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
- return `
-
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;border-bottom: 1px solid #EEEEEE;">
- <span style="font-size: 14px;color: #999;">更新时间</span>
- <span style="color: #333;font-size: 14px;">${row.update_time}</span>
- </div>
- <div style="display: flex;align-items: center;justify-content:space-between;padding: 0 20px;width: 250px;height: 66px;">
- <span style="font-size: 14px;color: #999;">权重</span>
- <span style="color: #FFA600;font-size: 14px;">${row.weigh}</span>
- </div>
- `
- }},
- {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;
- });
|