|
|
@@ -0,0 +1,382 @@
|
|
|
+<template>
|
|
|
+ <view class="app-content">
|
|
|
+ <form @submit="commitForm">
|
|
|
+ <view class="module-com input-line-wrap">
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title required">店名</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请填写店名、姓名或公司名" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title required">微信号</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请填写对方微信号" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title required">手机号</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请填写对方手机号" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title required">账单日期</view>
|
|
|
+ <input v-model="form.name" placeholder-class="phcolor" class="tui-input" name="name" placeholder="请选账单交易日期" maxlength="50" type="text" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <view class="tui-title required">账单金额</view>
|
|
|
+ <input v-model="form.price" placeholder-class="phcolor" class="tui-input" name="price" placeholder="请填写对方赖账金额" maxlength="50" type="digit" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="module-com input-line-wrap goods-wrap">
|
|
|
+ <view class="module-tit">
|
|
|
+ <span>图片证据</span>
|
|
|
+ <span class="app-color-3">(微信聊天截图、销售单拍照等,最多5张)</span>
|
|
|
+ </view>
|
|
|
+ <view class="module-det">
|
|
|
+ <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
|
|
|
+ @uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
|
|
|
+ </htz-image-upload>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="module-com input-line-wrap summary-wrap">
|
|
|
+ <view class="module-tit">其他说明</view>
|
|
|
+ <view class="module-det" style="padding-bottom: 20upx">
|
|
|
+ <textarea v-model="form.briefContent" class="goods-summary" placeholder-class="phcolor" placeholder="补充说明" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="app-footer">
|
|
|
+ <button class="admin-button-com middle default" @click="goBack">取消</button>
|
|
|
+ <button class="admin-button-com middle blue" formType="submit">保存</button>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </form>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+import TuiListCell from "@/components/plugin/list-cell";
|
|
|
+import AppUploader from "@/components/app-uploader";
|
|
|
+const form = require("@/utils/formValidation.js");
|
|
|
+import { getClass } from "@/api/category";
|
|
|
+import { addGoodsData } from "@/api/goods"
|
|
|
+import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
|
|
|
+import productMins from "@/mixins/product";
|
|
|
+import {currentShop} from "@/api/shop"
|
|
|
+export default {
|
|
|
+ name: "add",
|
|
|
+ components: { TuiListCell, AppUploader,htzImageUpload },
|
|
|
+ mixins: [productMins],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ headers:{token:''},
|
|
|
+ status: 1,
|
|
|
+ selectJobType: "addGoodsSelectItem",
|
|
|
+ form: {
|
|
|
+ name: "",
|
|
|
+ price: "",
|
|
|
+ catIds: [],
|
|
|
+ autoRise: "1",
|
|
|
+ needSend: "0",
|
|
|
+ freightType: "0",
|
|
|
+ shopImg: [],
|
|
|
+ briefContent: "",
|
|
|
+ status:1,
|
|
|
+ cover:'',
|
|
|
+ setItemNum:0,
|
|
|
+ kindId:0,
|
|
|
+ kindName:'',
|
|
|
+ inTurn:0,
|
|
|
+ stock:0
|
|
|
+ },
|
|
|
+ categoryData:[],
|
|
|
+ currentImgData:[]
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onLoad() {
|
|
|
+ const token = uni.getStorageSync('token')
|
|
|
+ this.headers.token = token
|
|
|
+ },
|
|
|
+ watch:{
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ changeKind(){
|
|
|
+ this.pageTo({url:'/admin/goods/selectKind?style=2&flower=1'})
|
|
|
+ },
|
|
|
+ selectItem(){
|
|
|
+ this.pageTo({url:'/admin/goods/selectItem'})
|
|
|
+ },
|
|
|
+ goBack(){
|
|
|
+ uni.navigateBack({delta:1})
|
|
|
+ },
|
|
|
+ imgDeleteFn(res){
|
|
|
+ const index = res.index
|
|
|
+ this.form.shopImg.splice(index,1)
|
|
|
+ },
|
|
|
+ imgUploadSuccess(res) {
|
|
|
+ var _res = JSON.parse(res.data)
|
|
|
+ if(_res.code == 1){
|
|
|
+ this.currentImgData.push(_res.data.smallUrl)
|
|
|
+ this.form.shopImg.push(_res.data.shortUrl)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ getClass({flower:1}).then(res => {
|
|
|
+ if(res.code && res.code == 1){
|
|
|
+ this.categoryData = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ confirmFn() {
|
|
|
+ let that = this
|
|
|
+ if (this.$util.isEmpty(this.form.catIds)) {
|
|
|
+ this.$msg("请选择分类");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (this.$util.isEmpty(this.form.shopImg)) {
|
|
|
+ this.$msg("请上传图片");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!this.form.kindId || Number(this.form.kindId) == 0){
|
|
|
+ this.$msg('请选择品种')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.$util.isEmpty(this.form.kindName)) {
|
|
|
+ this.$msg("请选择品种哦")
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ this.form.cover = this.form.shopImg[0]
|
|
|
+ const product = this.selectList.map(ele => {
|
|
|
+ let unitName = ele.bigUnit
|
|
|
+ let unitType = 0
|
|
|
+ let num = ele.bigCount
|
|
|
+ let count = ele.bigCount
|
|
|
+ if(Number(ele.smallCount)>0){
|
|
|
+ unitType = 1
|
|
|
+ unitName = ele.smallUnit
|
|
|
+ num=Number(ele.smallCount)
|
|
|
+ count = (ele.smallCount/ele.ratio).toFixed(2)
|
|
|
+ }
|
|
|
+ return { id: ele.id, unitType:unitType,ptItemId:ele.itemId,bigName:ele.bigUnit,smallName:ele.smallUnit,unitName:unitName,cover:ele.shortCover,
|
|
|
+ name:ele.name,ratio:ele.ratio,num:num,count:count}
|
|
|
+ })
|
|
|
+ that.$util.confirmModal({content:'确认添加?'},() => {
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ let form = JSON.parse(JSON.stringify(this.form));
|
|
|
+ addGoodsData({ status: this.status, ...form,itemList:JSON.stringify(product) }).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ this.$msg("添加成功")
|
|
|
+ this.removeFromSaveDirect()
|
|
|
+ setTimeout(function(){
|
|
|
+ uni.navigateBack({})
|
|
|
+ },1500)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ selCategoryFn(item) {
|
|
|
+ let index = this.form.catIds.findIndex(e => e == item.id);
|
|
|
+ if (index == -1) {
|
|
|
+ this.form.catIds.push(item.id);
|
|
|
+ } else {
|
|
|
+ this.form.catIds.splice(index, 1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ autoRiseChange(e) {
|
|
|
+ this.form.autoRise = e == "0" ? "1" : "0";
|
|
|
+ },
|
|
|
+ needSendChange(e) {
|
|
|
+ this.form.needSend = e == "0" ? "1" : "0";
|
|
|
+ },
|
|
|
+ freightChange(e) {
|
|
|
+ this.form.freightType = e.detail.value;
|
|
|
+ },
|
|
|
+ setItemNumChange(e){
|
|
|
+ this.form.setItemNum = e.detail.value;
|
|
|
+ },
|
|
|
+ commitForm(e) {
|
|
|
+ let rules = [
|
|
|
+ {
|
|
|
+ name: "name",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请输入名称"]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "price",
|
|
|
+ rule: ["required"],
|
|
|
+ msg: ["请输入价格"]
|
|
|
+ }
|
|
|
+ ];
|
|
|
+ let formData = e.detail.value;
|
|
|
+ let checkRes = form.validation(formData, rules);
|
|
|
+ if (!checkRes) {
|
|
|
+ setTimeout(() => {
|
|
|
+ this.confirmFn();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$msg(checkRes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.app-content {
|
|
|
+ min-height: calc(100vh - 100upx);
|
|
|
+ padding-bottom: 100upx;
|
|
|
+}
|
|
|
+.module-com {
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ background-color: #fff;
|
|
|
+ color: $fontColor2;
|
|
|
+ .module-tit {
|
|
|
+ padding: 20upx 30upx;
|
|
|
+ font-size: 28upx;
|
|
|
+ }
|
|
|
+ .module-det {
|
|
|
+ padding: 0 30upx;
|
|
|
+ }
|
|
|
+}
|
|
|
+.category-wrap {
|
|
|
+ align-items: flex-start;
|
|
|
+ padding-bottom: 0 !important;
|
|
|
+ .tui-input {
|
|
|
+ @include disFlex(center, flex-start);
|
|
|
+ flex-wrap: wrap;
|
|
|
+ .admin-button-com {
|
|
|
+ margin-right: 20upx;
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ position: relative;
|
|
|
+ z-index: 9999;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.summary-wrap {
|
|
|
+ .goods-summary {
|
|
|
+ height: 200upx;
|
|
|
+ }
|
|
|
+}
|
|
|
+.app-footer {
|
|
|
+ justify-content: space-evenly;
|
|
|
+ z-index: 9999;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 46%;
|
|
|
+ padding-top:30upx;
|
|
|
+ padding-bottom:30upx;
|
|
|
+ }
|
|
|
+}
|
|
|
+.commodity-view {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ .commodity-list {
|
|
|
+ padding: 25upx;
|
|
|
+ .commodity-item {
|
|
|
+ display: flex;
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ .item-icon {
|
|
|
+ flex-shrink: 0;
|
|
|
+ width: 120upx;
|
|
|
+ height: 120upx;
|
|
|
+ }
|
|
|
+ .item-info {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: center;
|
|
|
+ flex: 1;
|
|
|
+ margin-left: 20upx;
|
|
|
+ .info-line {
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: flex-end;
|
|
|
+ .item-name {
|
|
|
+ color: black;
|
|
|
+ font-size: 30upx;
|
|
|
+ font-weight: 700;
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ width:360upx;
|
|
|
+ }
|
|
|
+ .item-price {
|
|
|
+ padding-right:30upx;
|
|
|
+ color: #333;
|
|
|
+ .price {
|
|
|
+ font-size: 28upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .item-type {
|
|
|
+ color: #999;
|
|
|
+ font-size: 24upx;
|
|
|
+ }
|
|
|
+ .item-count {
|
|
|
+ color: #666;
|
|
|
+ font-size: 24upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .summary-bar {
|
|
|
+ padding: 0 20upx;
|
|
|
+ height: 90upx;
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ border-top: 1px solid #eeeeee;
|
|
|
+ .operate-view {
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ align-items: center;
|
|
|
+ color: #3385ff;
|
|
|
+ font-size: 26upx;
|
|
|
+ .iconfont {
|
|
|
+ margin-right: 20upx;
|
|
|
+ font-size: 40upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .describe-view {
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ align-items: center;
|
|
|
+ color: #333;
|
|
|
+ font-size: 24upx;
|
|
|
+ .price {
|
|
|
+ font-weight: bold;
|
|
|
+ font-size: 30upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.infoAEdit {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ height: 60upx;
|
|
|
+ line-height: 80upx;
|
|
|
+ font-size: 28;
|
|
|
+ font-weight: 700;
|
|
|
+ color: #666;
|
|
|
+ padding: 0 20upx;
|
|
|
+ .iconfont {
|
|
|
+ margin-right: 15upx;
|
|
|
+ font-size: 30upx;
|
|
|
+ }
|
|
|
+ & > .editFlr {
|
|
|
+ position: relative;
|
|
|
+ color: #1890f3;
|
|
|
+ font-size: 26upx;
|
|
|
+ &:after {
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|