发表于: 2019-11-17 23:47:37
1 1036
今日完成
规格:查询的表很多
- 点击规格,跳转到id=spec的位置:goods_edit.html
- 界面:从上向下分析
- 是否启用规格
- 点击勾选框,勾选则值为1,否在值为0
- 点击勾选框,勾选则值为1,否在值为0
- 屏幕尺寸/网络制式
- 页面需要specList域(注意各个域到底代表什么)
- 当商品基本信息中的模板ID发生变化后,触发goodsController.js中$scope.$watch("entity.goods.typeTemplateId"
- 需要规格 + 规格选项:tb_type_template表中spec_ids中包含的内容只有规格内容——>需要查询语句tb_specification_option表中查询option_name的内容
- 根据模板ID获得规格的列表的数据,response值为List<Map>(Json格式的字符串)
- List<Map>格式为:[{"id":27,"text":"网络","options":optionList},{"id":32,"text":"机身内存","options":optionList}]
- 调用typeTemplateService.findBySpecList()
- 调用typeTemplateService.findBySpecList():路径/typeTemplate/findBySpecLis,即调用TemplateController中的findBySpecList()函数
- findBySpecList()函数
- 根据模板id, 查询规格集合(tb_specification表)+ 对应的规格选项集合(tb_specification_option表)数据
- 数据格式
- 调用templateService.findBySpecList()
- 调用templateService.findBySpecList()
- TemplateService
- TemplateServiceImpl:调用templateDao.selectByPrimaryKey()(tb_type_template表中的spec_ids列) + optionDao.selectByExample()(tb_specification_option表)
- 查询出的格式
- TemplateService
- 调用templateDao.selectByPrimaryKey()(tb_type_template表中的spec_ids列) + 调用optionDao.selectByExample()(tb_specification_option表)
- 调用templateDao.selectByPrimaryKey()
- TypeTemplateDao
- TypeTemplateDao.xml
- TypeTemplateDao
- 调用optionDao.selectByExample()
- SpecificationOptionDao
- SpecificationOptionDao.xml
- SpecificationOptionDao
- 调用templateDao.selectByPrimaryKey()
- 当商品基本信息中的模板ID发生变化后,触发goodsController.js中$scope.$watch("entity.goods.typeTemplateId"
- 页面展示内容(注意各个域代表的内容)
- 使用goodsController.js中的specList域,格式为:[{"id":27,"text":"网络","options":[SpecificationOption1,SpecificationOption2...]}...{}..{}]
- 使用goodsController.js中的specList域,格式为:[{"id":27,"text":"网络","options":[SpecificationOption1,SpecificationOption2...]}...{}..{}]
- 页面需要specList域(注意各个域到底代表什么)
- 点击选择框跳出来对应行
- 点击选择框,调用的函数:checkAttributeValue()函数;updateSpecAttribute()函数;createItemList()函数
- ng-checked:设置复选框/单选框,若返回true则选中;$event:获取鼠标事件/键盘事件
- ng-checked:设置复选框/单选框,若返回true则选中;$event:获取鼠标事件/键盘事件
- 第一次勾选选择框
- updateSpecAttribute()函数:创建$scope.entity.goodsDesc.specificationItems域,相当于List中添加多个{}
- createItemList()函数:创建$scope.entity.itemList域,调用addColumn()函数
- 调用addColumn()函数:结果为 {spec:{items[i].attributeName:items[i].attributeValue},price:0,num:9999,status:'0',isDefault:'0'},赋值给$scope.entity.itemList域
- checkAttributeValue()函数:第一次勾选上,返回true——>在页面显示勾选
- searchObjectByKey()函数:第一次勾选上,返回那条数据;
- 页面显示
- 标题
- 内容显示
- 标题
- updateSpecAttribute()函数:创建$scope.entity.goodsDesc.specificationItems域,相当于List中添加多个{}
- #第二次勾选选择框,在同一个specname下
- 比如第一次勾选网络/移动4G,第二次勾选 网络/联通4G
- updateSpecAttribute()函数
- 刚进入函数$scope.entity.goodsDesc.specificationItems格式为[{"attributeName":"网络,"attributeValue":["移动4G"]}],不为空——>attributeName有对应的值,searchObjectByKey()函数返回符合的那条数据:{"attributeName":"网络,"attributeValue":["移动4G"]}
- 如果 网络/联通4G 勾选了,则往attributeValue这个list中添加数据,格式为:{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}
- 判断attributeValue中是否还有内容(由勾选变为不勾选的场景下使用),如果为空,则删除此条数据
- 刚进入函数$scope.entity.goodsDesc.specificationItems格式为[{"attributeName":"网络,"attributeValue":["移动4G"]}],不为空——>attributeName有对应的值,searchObjectByKey()函数返回符合的那条数据:{"attributeName":"网络,"attributeValue":["移动4G"]}
- createItemList()函数:此时$scope.entity.goodsDesc.specificationItems域格式为[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]
- 调用addColumn()函数:$scope.entity.itemList域格式为[{spec:{"网络":"移动4G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G"},price:0,num:9999,status:'0',isDefault:'0'}]
- checkAttributeValue()函数:此时$scope.entity.goodsDesc.specificationItems域格式为[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]
- 页面显示
- $scope.entity.goodsDesc.specificationItems域:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]
- $scope.entity.itemList域:[{spec:{"网络":"移动4G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G"},price:0,num:9999,status:'0',isDefault:'0'}]
- 标题
- 内容
- 比如第一次勾选网络/移动4G,第二次勾选 网络/联通4G
- 取消第二次勾选选择框
- 比如取消勾选机身内存/128G
- updateSpecAttribute()函数
- 刚进入函数$scope.entity.goodsDesc.specificationItems格式为[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}],不为空——>attributeName有对应的值,searchObjectByKey()函数返回符合的那条数据:{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}
- 如果 网络/联通4G 取消勾选了,则往attributeValue这个list中删除数据,格式为:{"attributeName":"网络,"attributeValue":["移动4G"]}
- 判断attributeValue中是否还有内容(由勾选变为不勾选的场景下使用),如果为空,则删除此条数据
- 刚进入函数$scope.entity.goodsDesc.specificationItems格式为[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}],不为空——>attributeName有对应的值,searchObjectByKey()函数返回符合的那条数据:{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}
- createItemList()函数:此时$scope.entity.goodsDesc.specificationItems域格式为[{"attributeName":"网络,"attributeValue":["移动4G"]}]
- createItemList()函数:此时$scope.entity.goodsDesc.specificationItems域格式为[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]
- 调用addColumn()函数:$scope.entity.itemList域格式为[{spec:{"网络":"移动4G"},price:0,num:9999,status:'0',isDefault:'0'}}]
- checkAttributeValue()函数:此时$scope.entity.goodsDesc.specificationItems域格式为[{"attributeName":"网络,"attributeValue":["移动4G"]}]
- 页面显示
- $scope.entity.goodsDesc.specificationItems域:[{"attributeName":"网络,"attributeValue":["移动4G"]}]
- $scope.entity.itemList域:[{spec:{"网络":["移动4G"]},price:0,num:9999,status:'0',isDefault:'0'}]
- 标题
- 内容
- 比如取消勾选机身内存/128G
- 第三次勾选选择框,不在同一个specname下
- 比如第一次勾选网络/移动4G,第二次勾选联通4G,第三次勾选机身内存/128G
- updateSpecAttribute()函数
- 刚进入函数,$scope.entity.goodsDesc.specificationItems格式为:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]——>attributeName没有对应的值"机身内存",searchObjectByKey()函数返回null
- 此时$scope.entity.goodsDesc.specificationItems格式为:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]},{"attributeName":"机身内存,"attributeValue":["128G"]}]
- 刚进入函数,$scope.entity.goodsDesc.specificationItems格式为:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]}]——>attributeName没有对应的值"机身内存",searchObjectByKey()函数返回null
- createItemList()函数:此时$scope.entity.goodsDesc.specificationItems域格式为:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]},{"attributeName":"机身内存,"attributeValue":["128G"]}]
- 第一个for循环,此时返回的$scope.entity.itemList域 与 #第二次勾选选择框,在同一个specname下
- 此时传入的 $scope.entity.itemList域 为 [{spec:{},price:0,num:9999,status:'0',isDefault:'0'}];
- items[1].attributeName 为 网络;items[1].attributeValue 为 ["移动4G","联通4G"]
- 调用addColumn()函数:$scope.entity.itemList域格式为[{spec:{"网络":"移动4G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G"},price:0,num:9999,status:'0',isDefault:'0'}]
- 第二个for循环
- 此时传入的 $scope.entity.itemList域格式为[{spec:{"网络":"移动4G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G"},price:0,num:9999,status:'0',isDefault:'0'}]
- items[2].attributeName 为 机身内存;items[2].attributeValue 为 128G
- 调用addColumn()函数:$scope.entity.itemList域格式为[{spec:{"网络":"移动4G","机身内存":"128G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G","机身内存":"128G"},price:0,num:9999,status:'0',isDefault:'0'}]
- 调用addColumn()函数:$scope.entity.itemList域格式为:
- checkAttributeValue()函数:此时$scope.entity.goodsDesc.specificationItems域格式为:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]},{"attributeName":"机身内存,"attributeValue":["128G"]}]
- 页面显示
- $scope.entity.goodsDesc.specificationItems域:[{"attributeName":"网络,"attributeValue":["移动4G","联通4G"]},{"attributeName":"机身内存,"attributeValue":["128G"]}]
- $scope.entity.itemList域:[{spec:{"网络":"移动4G","机身内存":"128G"},price:0,num:9999,status:'0',isDefault:'0'},{spec:{"网络":"联通4G","机身内存":"128G"},price:0,num:9999,status:'0',isDefault:'0'}]
- 标题
- 内容
- 比如第一次勾选网络/移动4G,第二次勾选联通4G,第三次勾选机身内存/128G
- 点击选择框,调用的函数:checkAttributeValue()函数;updateSpecAttribute()函数;createItemList()函数
明日计划
保存到多张表
评论