代码优化

This commit is contained in:
GaoHao
2025-03-26 13:34:19 +08:00
parent e928fdfa2a
commit 413222a5f0
42 changed files with 166 additions and 531 deletions

View File

@@ -81,7 +81,7 @@
<view class="u-flex color-999 " @tap="delproGroupVo(index)">
<uni-icons type="minus-filled" :size="16"
:color="color.ColorRed"></uni-icons>
:color="$utils.ColorRed"></uni-icons>
<view class="u-m-l-10">删除套餐组</view>
</view>
</view>
@@ -90,7 +90,7 @@
<view class="u-flex color-main u-font-24 u-m-l-24"
@click="proGroupVoAddGoods(index,item.goods)">
<up-icon name="plus" :size="12"
:color="color.ColorMain"></up-icon>
:color="$utils.ColorMain"></up-icon>
<view class="font-bold">添加商品</view>
</view>
</view>
@@ -150,7 +150,7 @@
</view>
<up-icon @click="proGroupVoGoodsDel(index,goodsIndex)"
size="14" name="trash"
:color="color.ColorMain"></up-icon>
:color="$utils.ColorMain"></up-icon>
</view>
</view>
</view>
@@ -173,7 +173,7 @@
<template v-if="FormData.groupType==1">
<view class="bg-fff u-flex u-p-t-24 u-p-b-24 border-r-12 "
@tap="proGroupVoPush">
<uni-icons type="plus-filled" :color="color.ColorMain"
<uni-icons type="plus-filled" :color="$utils.ColorMain"
:size="20"></uni-icons>
<view class="u-m-l-16">添加套餐组</view>
</view>
@@ -181,7 +181,7 @@
<template v-else>
<view class="bg-fff u-flex u-p-t-24 u-p-b-24 border-r-12 "
@tap="proGroupVoAddGoods()">
<uni-icons type="plus-filled" :color="color.ColorMain"
<uni-icons type="plus-filled" :color="$utils.ColorMain"
:size="20"></uni-icons>
<view class="u-m-l-16">添加商品</view>
</view>
@@ -423,29 +423,13 @@
</template>
<script setup>
import {
computed,
onBeforeUnmount,
reactive,
ref,
watch,
nextTick
} from 'vue';
import {
onLoad,
onShow,
onReady
} from '@dcloudio/uni-app';
import {
ColorMain
} from '@/commons/color.js'
import { computed, onBeforeUnmount, reactive, ref, watch, nextTick } from 'vue';
import { onLoad, onShow, onReady } from '@dcloudio/uni-app';
import dayjs from "dayjs";
import {
formatPrice
} from "@/commons/utils/format.js";
import { formatPrice } from "@/commons/utils/format.js";
import go from '@/commons/utils/go.js';
import color from '@/commons/color.js';
import chooseGoods from './components/choose-goods'
import chooseGuige from './components/choose-guige'
@@ -458,7 +442,7 @@
import { hasPermission } from '@/commons/utils/hasPermission.js';
import { $types, $defaultSku } from '@/commons/goodsData.js'
import { $defaultSku } from '@/commons/goodsData.js'
import {
getCategoryList,

View File

@@ -9,7 +9,7 @@
</view>
</view>
<view class="u-m-t-24">
<uni-data-checkbox :selectedColor="color.ColorMain" multiple v-model="item.cycleChecked"
<uni-data-checkbox :selectedColor="$utils.ColorMain" multiple v-model="item.cycleChecked"
:localdata="cycle"></uni-data-checkbox>
</view>
<view class="u-m-t-24">
@@ -50,7 +50,6 @@
import { onLoad, onReady } from '@dcloudio/uni-app';
import { computed, ref } from 'vue';
import go from '@/commons/utils/go.js';
import color from '@/commons/color.js'
import { getProductDetail } from '@/http/api/product.js'

View File

@@ -24,7 +24,7 @@
<view class="u-m-t-16">
<uni-data-checkbox @change="createResult" multiple :selectedColor="color.ColorMain"
<uni-data-checkbox @change="createResult" multiple :selectedColor="$utils.ColorMain"
v-model="item.selectSpecResult" :localdata="item.children">
</uni-data-checkbox>
@@ -129,7 +129,7 @@
<button class="save-btn edit-btn" hover-class="btn-hover-class" @click="fastEditShow">
<view class="u-flex u-row-center">
<view class="u-m-r-6">批量修改</view>
<up-icon name="edit-pen" :color="color.ColorMain"></up-icon>
<up-icon name="edit-pen" :color="$utils.ColorMain"></up-icon>
</view>
</button>
</view>
@@ -149,7 +149,6 @@
import infoBox from '@/commons/utils/infoBox.js'
import dayjs from "dayjs";
import go from '@/commons/utils/go.js';
import color from '@/commons/color.js';
import { $defaultSku } from '@/commons/goodsData.js'
import { hasPermission } from '@/commons/utils/hasPermission.js';

View File

@@ -36,21 +36,8 @@
</template>
<script setup>
import {
reactive,
ref,
watch,
onMounted,
computed
} from 'vue';
import {
returnSkuSnap,
returnTypeEnum,
returnCategory
} from '@/pageProduct/util.js'
import {
$tbShopUnit
} from '@/http/yskApi/goods.js'
import { reactive, ref, watch, computed } from 'vue';
const props = defineProps({
show: {
type: Boolean,

View File

@@ -1,30 +1,4 @@
import dayjs from "dayjs";
export const $types = [{
title: "计量商品",
desc: '单价购买',
value: 'normal'
},
{
title: "多规格",
desc: '多种不同规格',
value: 'sku'
},
{
title: "套餐组合",
desc: '选择多种组合',
value: 'group'
},
{
title: "称重商品",
desc: '按重量售卖',
value: 'weight'
},
{
title: "时价商品",
desc: '收银端可更改价格',
value: 'currentPrice'
}
]
// 商品默认sku
export const $defaultSku = {
@@ -36,38 +10,3 @@ export const $defaultSku = {
suitNum: 1,
barCode: `${uni.getStorageSync("shopId")}${dayjs().valueOf()}`,
}
// 库存记录筛选类型
export const $invoicingType = [{
text: '全部',
value: ''
},
{
text: '供应商入库',
value: 'purveyor'
},
{
text: '供应商退货',
value: 'reject'
},
{
text: '其他入库',
value: 'purchase'
},
{
text: '其他出库',
value: 'other-out'
}
]
// 页面常用数据
export const $pageData = {
query: {
page: 0,
size: 10
},
totalElements: 0,
list: [],
hasAjax: false,
}

View File

@@ -85,7 +85,6 @@
<script setup>
import { computed, reactive, ref, watch, onMounted } from 'vue';
import { returnSkuSnap, returnTypeEnum, returnCategory } from '@/pageProduct/util.js'
import { formatPrice } from "@/commons/utils/format.js";
const emits = defineEmits(['update:show', 'save'])

View File

@@ -112,7 +112,6 @@
<script setup>
import { reactive, ref, watch, onMounted, computed } from 'vue';
import { $invoicingType } from '@/commons/goodsData.js'
import { productStockFlow } from '@/http/api/product.js'
import go from '@/commons/utils/go.js'
const refForm = ref(null)
@@ -173,22 +172,18 @@
getProductStockDetail()
}
})
let getTypeName = (type) => {
let item = $invoicingType.filter(item=> item.value == type)[0]
return item?item.text:''
}
async function getProductStockDetail(){
const { records }=await productStockFlow({
page: 1,
size: 2,
productId: props.goods.id,
})
console.log(records);
recoders.list = records.map(v=>{
return {
...v,
title: v.createTime,
content: getTypeName(v.inOutItem)+':'+Math.abs(v.inOutNumber)
content: uni.$dict.getDiceName(v.inOutItem,'invoicingType')+':'+Math.abs(v.inOutNumber)
}
})
}

View File

@@ -7,7 +7,7 @@
<text class="u-m-l-20">{{data.sort}}</text>
</view>
<view class="color-333 u-m-l-42 u-flex">
<up-icon @click="editStock" name="edit-pen" :size="16" :color="ColorMain"></up-icon>
<up-icon @click="editStock" name="edit-pen" :size="16" :color="$utils.ColorMain"></up-icon>
<text class="stock u-m-l-4">库存:{{data.stockNumber}}</text>
</view>
</view>
@@ -21,7 +21,7 @@
<view class="u-m-t-48 u-flex u-col-top u-relative">
<view v-if="props.showChecked">
<label class="radio">
<radio :color="ColorMain" style="transform: scale(0.7);" @click="radioClick"
<radio :color="$utils.ColorMain" style="transform: scale(0.7);" @click="radioClick"
:checked="props.data.checked" /><text></text>
</label>
</view>
@@ -102,7 +102,7 @@
import { updateProduct,productOnOff,productMarkIsSoldOut } from '@/http/api/product.js'
import go from '@/commons/utils/go.js';
import {hasPermission} from '@/commons/utils/hasPermission.js';
import { ColorMain } from '@/commons/color.js'
const emits = defineEmits(['radioClick', 'xiajia', 'del', 'changePrice', 'baosun', 'guigeClick','update',
'editStock'
])

View File

@@ -203,7 +203,6 @@
size: 200
}).then(res => {
pageData.categoryList = returnAllCategory(res)
console.log(pageData.categoryList);
})
}

View File

@@ -4,7 +4,7 @@
<view class="">
<uni-dateformat format="yyyy-MM-dd hh:mm:ss" :date="data.createTime"></uni-dateformat>
</view>
<view class="tag">{{getTypeName(data.inOutItem)}}</view>
<view class="tag">{{$dict.getDiceName(data.inOutItem,'invoicingType')}}</view>
</view>
<view class="u-flex u-text-left u-row-left u-m-t-30">
<view class="name up-line-1">{{data.productName}}</view>
@@ -52,8 +52,7 @@
<script setup>
import { reactive } from 'vue';
import go from '@/commons/utils/go.js'
import { $invoicingType } from '@/commons/goodsData.js'
const props = defineProps({
data: {
type: Object,
@@ -63,10 +62,6 @@
}
})
let getTypeName = (type) => {
let item = $invoicingType.filter(item=> item.value == type)[0]
return item?item.text:''
}
</script>

View File

@@ -70,8 +70,7 @@
import { ref, reactive, computed, watch } from 'vue';
import myListItem from './components/list-item.vue';
import { $invoicingType } from '@/commons/goodsData.js'
import { productStockFlow } from '@/http/api/product.js'
@@ -98,7 +97,7 @@
// 库存分类
const types = reactive({
list:$invoicingType,
list: uni.$dict.invoicingType,
active: '',
show: false,
bottomHeight: 14

View File

@@ -1,4 +1,4 @@
import { $types } from '@/commons/goodsData.js'
export function returnSkuSnap(goods) {
const selectSpec = typeof goods.selectSpec === 'string' ? JSON.parse(goods.selectSpec) : goods.selectSpec
let result = selectSpec.map(v => {
@@ -9,11 +9,7 @@ export function returnSkuSnap(goods) {
})
return result
}
export function returnTypeEnum(type) {
const item = $types.find(v => v.title == type)
let result = item ? item.value : undefined
return result
}
export function returnCategory(cateName, cateList) {
console.log(cateName);
console.log(cateList);