| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- import { shallowRef, reactive } from 'vue'
- import { v4 } from 'uuid'
- import { ClientType } from '@/constants/client'
- import { useDataTable } from '@/hooks/datatable'
- import { Market } from '@/constants/market'
- import { queryDiamondList } from '@/services/api/goods'
- import { zsBuyOrderListing, zsSellOrderListing } from '@/services/api/order'
- import { sessionData } from '@/stores'
- import {
- Category,
- getCategoryList,
- getCurrencyTypeList,
- getShapeTypeList,
- getColorTypeList,
- getCutTypeList,
- getClarityTypeList,
- getPolishTypeList,
- getSymmetryTypeList,
- getFluorescenceTypeList,
- getCrystalTypeList,
- getFancyColorType1List,
- getStyleTypeList,
- } from '@/constants/diamond'
- import moment from 'moment'
- import Long from 'long'
- /**
- * 求购大厅挂牌
- * @returns
- */
- export function useBuyOrderListing() {
- const { UserID, AccountIDs } = sessionData.getValue('loginInfo')
- const loading = shallowRef(false)
- const performanceId = shallowRef<number>() // 选中的履约模板ID
- const currencyId = shallowRef<number>() // 选中的货币类型ID
- const formData = reactive<Proto.GZBuyOrderDetailExInfo>({
- UserID,
- AccountID: AccountIDs[0],
- ZSCategory: Category.Diamonds,
- ZSCurrencyType: [],
- ZSShapeType: [],
- ZSColorType: [],
- ZSClarityType: [],
- ZSCutType: [],
- ZSSymmetryType: [],
- ZSPolishType: [],
- ZSFluorescenceType: [],
- Size: [],
- ZSCrystalType: [],
- Origin: '',
- ZSStyleType: [],
- ZSCZColor1Type: [],
- })
- const enums = {
- categoryList: getCategoryList(),
- currencyTypeList: getCurrencyTypeList(),
- shapeTypeList: getShapeTypeList(),
- colorTypeList: getColorTypeList(),
- cutTypeList: getCutTypeList(),
- clarityTypeList: getClarityTypeList(),
- polishTypeList: getPolishTypeList(),
- symmetryTypeList: getSymmetryTypeList(),
- fluorescenceTypeList: getFluorescenceTypeList(),
- crystalTypeList: getCrystalTypeList(),
- fancyColorType1List: getFancyColorType1List(),
- styleTypeList: getStyleTypeList(),
- }
- const formSubmit = () => {
- loading.value = true
- if (formData.Size.some((val) => !val)) {
- formData.Size = []
- }
- return zsBuyOrderListing({
- data: {
- Header: {
- AccountID: AccountIDs[0],
- },
- UserID,
- AccountID: AccountIDs[0],
- MarketID: Market.GZ,
- OrderSrc: 2,
- ClientType: ClientType.Web,
- ClientSerialNo: v4(),
- PerformanceTemplateID: performanceId.value,
- GZ_BuyOrderDetailExInfo: formData
- },
- complete: () => {
- loading.value = false
- }
- })
- }
- return {
- loading,
- performanceId,
- currencyId,
- formData,
- enums,
- formSubmit,
- }
- }
- /**
- * 出售大厅挂牌
- * @returns
- */
- export function useSellOrderListing() {
- const { dataList } = useDataTable<Ermcp.MyWRPositionRsp>()
- const { UserID, AccountIDs } = sessionData.getValue('loginInfo')
- const submitLoading = shallowRef(false)
- const tableLoading = shallowRef(false)
- const columns = shallowRef<Ermcp.TableColumn[]>([])
- const categoryList = getCategoryList() // 分类列表
- const selectedCategoryId = shallowRef(Category.Diamonds)
- const formData = reactive<Proto.ZSSellOrderListingReq>({
- Header: {
- AccountID: AccountIDs[0],
- },
- UserID,
- AccountID: AccountIDs[0],
- WRStandardID: 0,
- OrderQty: 0,
- LadingBillID: Long.fromNumber(0),
- SubNum: 0,
- TimevalidType: 4, // 4:一直有效
- OrderSrc: 2,
- ClientSerialNo: '',
- ClientOrderTime: '',
- ClientType: ClientType.Web,
- MarketID: Market.GZ,
- })
- // 获取商品列表
- const getDiamondList = () => {
- dataList.value = []
- formData.WRStandardID = 0
- tableLoading.value = true
- queryDiamondList({
- data: {
- wruserid: UserID,
- zscategory: selectedCategoryId.value,
- },
- success: (res) => {
- dataList.value = res.data.filter((e) => e.ftotalqty - e.ffreezeqty > 0)
- },
- complete: () => {
- tableLoading.value = false
- }
- })
- }
- // 切换商品分类
- const categoryChange = () => {
- switch (selectedCategoryId.value) {
- case Category.Diamonds: {
- columns.value = [
- {
- prop: 'goodsno',
- label: '商品编号',
- show: true,
- },
- {
- prop: 'price',
- label: '总价',
- show: true,
- },
- {
- prop: 'weight',
- label: '总重量',
- show: true,
- },
- {
- prop: 'weightavg',
- label: '平均单颗重量',
- show: true,
- },
- {
- prop: 'priceper',
- label: '克拉单位',
- show: true,
- },
- {
- prop: 'ftotalqty',
- label: '库存重量',
- show: true,
- },
- {
- prop: 'remainqty',
- label: '剩余重量',
- show: true,
- },
- {
- prop: 'zsshapetypedisplay',
- label: '形状',
- show: true,
- width: 200,
- },
- {
- prop: 'zscolortype',
- label: '颜色',
- show: true,
- },
- {
- prop: 'zsclaritytype',
- label: '净度',
- show: true,
- }
- ]
- break
- }
- case Category.Diamond: {
- columns.value = [
- {
- prop: 'goodsno',
- label: '商品编号',
- show: true,
- },
- {
- prop: 'price',
- label: '价格',
- show: true,
- },
- {
- prop: 'weight',
- label: '克拉重量',
- show: true,
- },
- {
- prop: 'priceper',
- label: '克拉单位',
- show: true,
- },
- {
- prop: 'zsshapetypedisplay',
- label: '形状',
- width: 200,
- show: true,
- },
- {
- prop: 'zscolortype1display',
- label: '颜色',
- show: true,
- },
- {
- prop: 'zsclaritytype1display',
- label: '净度',
- show: true,
- }
- ]
- break
- }
- case Category.Rough: {
- columns.value = [
- {
- prop: 'goodsno',
- label: '商品编号',
- show: true,
- },
- {
- prop: 'price',
- label: '总价',
- show: true,
- },
- {
- prop: 'weight',
- label: '总重量',
- show: true,
- },
- {
- prop: 'weightavg',
- label: '平均单颗重量',
- show: true,
- },
- {
- prop: 'priceper',
- label: '克拉单位',
- show: true,
- },
- {
- prop: 'ftotalqty',
- label: '库存重量',
- show: true,
- },
- {
- prop: 'remainqty',
- label: '剩余重量',
- show: true,
- },
- {
- prop: 'zscrystaltypedisplay',
- label: '晶型',
- width: 200,
- show: true,
- },
- {
- prop: 'zscolortype',
- label: '颜色',
- show: true,
- },
- {
- prop: 'zsclaritytype',
- label: '净度',
- show: true,
- }
- ]
- break
- }
- case Category.Jewelry: {
- columns.value = [
- {
- prop: 'goodsno',
- label: '商品编号',
- show: true,
- },
- {
- prop: 'price',
- label: '价格',
- show: true,
- },
- {
- prop: 'weight',
- label: '主石重量',
- show: true,
- },
- {
- prop: 'priceper',
- label: '克拉单位',
- show: true,
- },
- {
- prop: 'zsstyletypedisplay',
- label: '款式',
- width: 200,
- show: true,
- },
- {
- prop: 'zsstyletypedisplay',
- label: '主石形状',
- width: 200,
- show: true,
- },
- {
- prop: 'zsclaritytype1display',
- label: '主石净度',
- show: true,
- },
- {
- prop: 'zscuttype1display',
- label: '主石切工',
- show: true,
- },
- {
- prop: 'zssymmetrytype1display',
- label: '主石对称度',
- show: true,
- }
- ]
- break
- }
- case Category.Fancy: {
- columns.value = [
- {
- prop: 'goodsno',
- label: '商品编号',
- show: true,
- },
- {
- prop: 'price',
- label: '价格',
- show: true,
- },
- {
- prop: 'weight',
- label: '克拉重量',
- show: true,
- },
- {
- prop: 'priceper',
- label: '克拉单位',
- show: true,
- },
- {
- prop: 'zsshapetypedisplay',
- label: '形状',
- width: 200,
- show: true,
- },
- {
- prop: 'zsczcolortype',
- label: '颜色',
- width: 200,
- show: true,
- },
- {
- prop: 'zsclaritytype1display',
- label: '净度',
- show: true,
- }
- ]
- break
- }
- }
- getDiamondList()
- }
- const formSubmit = () => {
- submitLoading.value = true
- return zsSellOrderListing({
- data: {
- ...formData,
- ClientSerialNo: v4(),
- ClientOrderTime: moment().format('YYYY-MM-DD HH:mm:ss')
- },
- complete: () => {
- submitLoading.value = false
- }
- })
- }
- // 初始化
- categoryChange()
- return {
- submitLoading,
- tableLoading,
- formData,
- dataList,
- columns,
- categoryList,
- selectedCategoryId,
- categoryChange,
- formSubmit,
- }
- }
|