mulSpecification.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="container">
  3. <view class="title">
  4. <view class="search_box"><search holder="请输入规格名称" @getList="getSpecList"></search></view>
  5. <view class="administration" @click="handleAdministration">{{ administrationFlag ? '完成' : '管理' }}</view>
  6. </view>
  7. <select-form :platformClassification="selectFormList" @handleJumpLogic="handleJumpLogic"></select-form>
  8. <view class="finish" v-if="administrationFlag">
  9. <view @click="selectAll">
  10. <span :class="{ 'select': allSelect }">
  11. <span v-if="allSelect" class="iconfont">&#xe646;</span>
  12. </span>
  13. <span>全选({{ selectNum }})</span>
  14. </view>
  15. <view @click="subDel">删除</view>
  16. </view>
  17. <view class="handle" v-else><view class="handle_button" @click="newSpecifications">新增规格</view></view>
  18. </view>
  19. </template>
  20. <script>
  21. // +----------------------------------------------------------------------
  22. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  23. // +----------------------------------------------------------------------
  24. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  25. // +----------------------------------------------------------------------
  26. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  27. // +----------------------------------------------------------------------
  28. // | Author: CRMEB Team <admin@crmeb.com>
  29. // +----------------------------------------------------------------------
  30. import { navigateTo } from '../../../libs/uniApi.js';
  31. import search from '../components/search.vue';
  32. import selectForm from '../components/selectForm.vue';
  33. import { specificationLst, specificationDel } from "@/api/product";
  34. export default {
  35. components: {
  36. search,
  37. selectForm
  38. },
  39. data() {
  40. return {
  41. allSelect: false, // 全选按钮
  42. administrationFlag: false,
  43. selectNum: 0,
  44. mer_id: '',
  45. where: {
  46. page: 1,
  47. limit: 999
  48. },
  49. selectFormList: [
  50. ]
  51. };
  52. },
  53. watch: {
  54. selectFormList: {
  55. handler(val) {
  56. console.log(val);
  57. this.selectNum = val.filter(item => item.select).length;
  58. if(this.selectNum == val.length) {
  59. this.allSelect = true;
  60. } else {
  61. this.allSelect = false;
  62. }
  63. },
  64. deep: true
  65. }
  66. },
  67. onLoad(options) {
  68. this.mer_id = options.mer_id
  69. this.getSpecList('')
  70. },
  71. methods: {
  72. // 点击列表项
  73. handleJumpLogic(item) {
  74. console.log(item);
  75. uni.navigateTo({
  76. url: `/pages/product/addGoods/specificationProperties?mer_id=${item.mer_id}&template_id=${item.attr_template_id}`
  77. })
  78. },
  79. //新增规格
  80. newSpecifications() {
  81. uni.navigateTo({
  82. url: `/pages/product/addGoods/specificationProperties?mer_id=${this.mer_id}`
  83. })
  84. },
  85. //全选
  86. selectAll() {
  87. this.allSelect = !this.allSelect;
  88. if(this.allSelect) {
  89. this.selectFormList.forEach(item => {
  90. this.$set(item, 'select', true);
  91. });
  92. } else {
  93. this.selectFormList.forEach(item => {
  94. this.$set(item, 'select');
  95. });
  96. }
  97. },
  98. handleAdministration() {
  99. this.administrationFlag = !this.administrationFlag;
  100. if (this.administrationFlag) {
  101. this.selectFormList.forEach(item => {
  102. this.$set(item, 'select', false);
  103. });
  104. } else {
  105. this.selectFormList.forEach(item => {
  106. this.$delete(item, 'select');
  107. });
  108. }
  109. },
  110. /*删除*/
  111. subDel(){
  112. let that = this
  113. let type_id = []
  114. that.selectFormList.forEach(item=>{
  115. if(item.select){
  116. type_id.push(item.attr_template_id)
  117. }
  118. })
  119. if(type_id.length == 0){
  120. return that.$util.Tips({
  121. title: '请选择规格'
  122. });
  123. }else{
  124. specificationDel(that.mer_id,{
  125. ids:type_id,
  126. }).then(res=>{
  127. that.$util.Tips({
  128. title: res.message,
  129. icon: 'success'
  130. });
  131. that.where.page = 1;
  132. that.selectFormList = [];
  133. that.getSpecList('');
  134. }).catch(err => {
  135. return that.$util.Tips({
  136. title: err
  137. });
  138. });
  139. }
  140. },
  141. /*获取规格列表*/
  142. getSpecList(keyword){
  143. let that = this;
  144. uni.showLoading({
  145. title: '加载中',
  146. mask: true
  147. });
  148. specificationLst(that.mer_id, { ...that.where, keyword: keyword }).then(
  149. res => {
  150. uni.hideLoading();
  151. that.selectFormList = res.data.list;
  152. // that.where.page = that.where.page + 1;
  153. that.selectFormList.forEach((item, i) => {
  154. that.$set(item, 'label', item.template_name);
  155. that.$set(item, 'id', item.attr_template_id);
  156. that.$set(item, 'mer_id', item.mer_id);
  157. that.$set(item, 'jumpLogic', true);
  158. that.$set(item, 'type', 'select');
  159. that.$set(item, 'select', false);
  160. if(!that.administrationFlag)that.$delete(item, 'select');
  161. })
  162. },
  163. error => {
  164. that.$util.Tips({
  165. title: error.msg
  166. })
  167. }
  168. );
  169. }
  170. }
  171. };
  172. </script>
  173. <style lang="scss" scoped>
  174. .container {
  175. padding-bottom: 130rpx;
  176. }
  177. .title {
  178. background: #fff;
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-between;
  182. padding: 30rpx 40rpx 30rpx 35rpx;
  183. .search_box {
  184. flex: 1;
  185. margin-right: 35rpx;
  186. }
  187. }
  188. .administration {
  189. color: #000000;
  190. font-size: 30rpx;
  191. }
  192. .handle {
  193. position: fixed;
  194. left: 0;
  195. bottom: 0;
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. width: 750rpx;
  200. height: 126rpx;
  201. background: #ffffff;
  202. &_button {
  203. display: flex;
  204. align-items: center;
  205. justify-content: center;
  206. color: #fff;
  207. font-size: 32rpx;
  208. width: 690rpx;
  209. height: 86rpx;
  210. background: #e93323;
  211. border-radius: 43rpx;
  212. }
  213. }
  214. .finish {
  215. display: flex;
  216. justify-content: space-between;
  217. align-items: center;
  218. padding: 0 30rpx;
  219. box-sizing: border-box;
  220. position: fixed;
  221. left: 0;
  222. bottom: 0;
  223. width: 100%;
  224. height: 126rpx;
  225. background: #ffffff;
  226. > view:nth-child(1) {
  227. display: flex;
  228. align-items: center;
  229. >span:nth-child(1) {
  230. width: 38rpx;
  231. height: 38rpx;
  232. border: 1px solid #cccccc;
  233. border-radius: 50%;
  234. display: inline-block;
  235. margin-right: 24rpx;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. }
  240. }
  241. > view:nth-child(2) {
  242. width: 180rpx;
  243. height: 70rpx;
  244. border: 1px solid #e93323;
  245. border-radius: 35px;
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. color: #e93323;
  250. }
  251. }
  252. .select {
  253. background: #E93323;
  254. border: none !important;
  255. .iconfont {
  256. color: #fff;
  257. font-size: 24rpx;
  258. }
  259. }
  260. </style>