更新时间:2022-01-15 14:45:02
更新说明:增加productId、productTypeId配置参数
更新时间:2021-12-23 09:13:00
更新说明:修复拖拽规格后删除规格/规格值出现的错乱问题
更新时间:2021-12-19 00:41:24
更新说明:增加使用说明以及修复同个商品类型值重复选中时的样式问题
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | <!doctype html> < html > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" > < meta http-equiv = "X-UA-Compatible" content = "ie=edge" > < title >动态SKU表</ title > <!-- 引入 layui.css --> < link rel = "stylesheet" type = "text/css" href = "./layui/css/layui.css" /> </ head > < body > < div id = "app" > < form action = "" class = "layui-form fairy-form" > <!--商品规格选项--> < div id = "fairy-is-attribute" ></ div > <!--商品类型选择--> < div id = "fairy-product-type" ></ div > <!--商品属性表--> < div id = "fairy-attribute-table" ></ div > <!--商品规格表--> < div id = "fairy-spec-table" ></ div > <!--商品库存表--> < div id = "fairy-sku-table" ></ div > < div > < div > < button lay-submit lay-filter = "submit" >立即提交</ button > < button type = "reset" class = "layui-btn layui-btn-primary" >重置</ button > </ div > </ div > </ form > </ div > <!-- 引入 layui.js --> < script src = "./layui/layui.js" ></ script > < script > layui.config({ base: './lay-module/', // 设定扩展的 layui 模块的所在目录,一般用于外部模块扩展 }).use(['layer', 'form', 'skuTable',], function () { var layer = layui.layer, form = layui.form, skuTable = layui.skuTable; var skuTableObj = skuTable.render({ isAttributeElemId: 'fairy-is-attribute', productTypeElemId: 'fairy-product-type', attributeTableElemId: 'fairy-attribute-table', specTableElemId: 'fairy-spec-table', skuTableElemId: 'fairy-sku-table', //商品规格模式 0单规格 1多规格 mode: 0, //是否开启sku表行合并 rowspan: true, //图片上传接口 uploadUrl: './json/upload.json', //获取商品类型接口 productTypeUrl: './json/productTypeData.json', //获取商品类型下的规格和属性接口 attrSpecUrl: './json/attrSpecData.json', //创建规格接口 specCreateUrl: './json/specCreate.json', //删除规格接口 specDeleteUrl: './json/specDelete.json', //创建规格值接口 specValueCreateUrl: './json/specValueCreate.json', //删除规格值接口 specValueDeleteUrl: './json/specValueDelete.json', //sku数据接口 skuDataUrl: './json/skuData.json', //单规格SKU表配置 singleSkuTableConfig: { thead: [ {title: '销售价(元)', icon: 'layui-icon-cols'}, {title: '市场价(元)', icon: 'layui-icon-cols'}, {title: '成本价(元)', icon: 'layui-icon-cols'}, {title: '库存', icon: 'layui-icon-cols'}, {title: '状态', icon: ''}, ], tbody: [ {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'}, {type: 'input', field: 'market_price', value: '0', verify: 'required|number', reqtext: '市场价不能为空'}, {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'}, {type: 'input', field: 'stock', value: '0', verify: 'required|number', reqtext: '库存不能为空'}, {type: 'select', field: 'status', option: [{key: '启用', value: '1'}, {key: '禁用', value: '0'}], verify: 'required', reqtext: '状态不能为空'}, ] }, //多规格SKU表配置 multipleSkuTableConfig: { thead: [ {title: '图片', icon: ''}, {title: '销售价(元)', icon: 'layui-icon-cols'}, {title: '市场价(元)', icon: 'layui-icon-cols'}, {title: '成本价(元)', icon: 'layui-icon-cols'}, {title: '库存', icon: 'layui-icon-cols'}, {title: '状态', icon: ''}, ], tbody: [ {type: 'image', field: 'picture', value: '', verify: '', reqtext: ''}, {type: 'input', field: 'price', value: '0', verify: 'required|number', reqtext: '销售价不能为空'}, {type: 'input', field: 'market_price', value: '0', verify: 'required|number', reqtext: '市场价不能为空'}, {type: 'input', field: 'cost_price', value: '0', verify: 'required|number', reqtext: '成本价不能为空'}, {type: 'input', field: 'stock', value: '0', verify: 'required|number', reqtext: '库存不能为空'}, { type: 'select', field: 'status', option: [{key: '启用', value: '1'}, {key: '禁用', value: '0'}], verify: '', reqtext: '' }, ] }, }); form.on('submit(submit)', function (data) { //获取表单数据 console.log(data.field); if (skuTableObj.getMode() == 0) { //单规格 layer.alert(JSON.stringify(data.field), {title: '提交的数据'}); } else { //多规格 var state = Object.keys(data.field).some(function (item, index, array) { return item.startsWith('skus'); }); state ? layer.alert(JSON.stringify(data.field), {title: '提交的数据'}) : layer.msg('sku表数据不能为空', {icon: 5, anim: 6}); } return false; }); }); </ script > </ body > </ html > |
更新时间:2021-12-16 00:44:50
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com