12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307 |
- <template>
- <el-form
- :model="ruleForm"
- status-icon
- :rules="rulesThis"
- ref="ruleForm"
- :size="'mini'"
- v-loading="loading"
- label-width="85px"
- class="demo-ruleForm"
- >
- <el-row>
- <el-col
- :span="24"
- style="padding: 12px 16px 12px 16px; text-align: right"
- >
- <!-- 贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用=成本合计 -->
- <!-- 贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费=成本合计 -->
- <!-- ps:没有其他费用-->
- <!-- (ruleForm.noble_weight*askItem.gold_price)+ (ruleForm.cost_fee*ruleForm.noble_weight)
- + ruleForm.mark_fee + ruleForm.pakge_fee + ruleForm.cert_fee + ruleForm.nake_fee + ruleForm.delivery_fee-->
- <!-- 乘法精度函数调用在mounted(初始调用),number_change函数(改变调用),如果放在dom层初始值时undifind会报错 r1,r2-->
- <span
- >成本合计:<span>
- {{
- accAdd(
- r1,
- r2,
- ruleForm.mark_fee,
- ruleForm.pakge_fee,
- ruleForm.cert_fee,
- ruleForm.nake_fee,
- ruleForm.delivery_fee,
- )
- }}
- <!-- {{ruleForm.delivery_fee}} -->
- </span></span
- >
- <span
- class="fl"
- style="height: 28px; font-size: 16px; line-height: 28px"
- >{{ title }}</span
- >
- <el-button :size="'mini'" @click="$emit('cancel')">取 消 </el-button>
- <el-button
- :size="'mini'"
- type="primary"
- v-if="type !== 'view'"
- @click="submitForm"
- >保 存
- </el-button>
- </el-col>
- <el-col :span="16">
- <el-form-item label="供应商" prop="supplierNo">
- <search-supplier
- :value="ruleForm.supplierNo"
- :placeholder="'供应商'"
- :size="'mini'"
- :names="supplierNo_name"
- :disabled="type === 'view'"
- :isDetail="type !== 'add'"
- @searchChange="supplierNosearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="品牌" prop="brandid" label-width="60px">
- <search-brand
- :value="ruleForm.brandid"
- :size="'mini'"
- :disabled="false"
- :isDetail="true"
- :names="brand_name"
- :placeholder="'品牌'"
- @searchChange="brandidsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="有效期" prop="expire_day">
- <digital-input
- :values="ruleForm.expire_day"
- :placeholder="'有效期'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="0"
- :size="'mini'"
- :disabled="type === 'view'"
- :controls="false"
- :append="'天'"
- @reschange="number_change($event, 'expire_day')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="物流时间" prop="delivery_day">
- <digital-input
- :values="ruleForm.delivery_day"
- :placeholder="'物流时间'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="0"
- :size="'mini'"
- :disabled="type === 'view'"
- :controls="false"
- :append="'天'"
- @reschange="number_change($event, 'delivery_day')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="生产工期" prop="work_day">
- <digital-input
- :values="ruleForm.work_day"
- :placeholder="'生产工期'"
- :min="0"
- :max="100000000000"
- :disabled="type === 'view'"
- :position="'right'"
- :precision="0"
- :size="'mini'"
- :controls="false"
- :append="'天'"
- @reschange="number_change($event, 'work_day')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="5">
- <el-form-item label="税点" prop="tax" label-width="60px">
- <search-tax
- :value="ruleForm.tax"
- :size="'mini'"
- :disabled="type === 'view'"
- :isDetail="type !== 'add'"
- :placeholder="'税点'"
- @searchChange="taxsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="单位" prop="unit_id" label-width="60px">
- <search-unit
- :value="ruleForm.unit_id"
- :size="'mini'"
- :isDetail="true"
- :names="unit_name"
- :disabled="false"
- :placeholder="'单位'"
- @searchChange="unitsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-row>
- <el-col :span="12">
- <el-form-item label="分类" prop="cat_id">
- <search-sort
- :value="ruleForm.cat_id"
- :placeholder="'分类'"
- :size="'mini'"
- :names="cat_id_name"
- :disabled="false"
- :isDetail="true"
- @searchChange="cat_id_change"
- />
- </el-form-item>
- <el-form-item label="商品名称" prop="pname">
- <el-input
- placeholder="商品名称"
- maxlength="100"
- :disabled="type === 'view'"
- v-model="ruleForm.pname"
- ></el-input>
- </el-form-item>
- <el-form-item label="产地" prop="origin_place">
- <select-area
- :placeholder="'产地'"
- :value="ruleForm.origin_place"
- :size="'mini'"
- :disabled="type === 'view'"
- :is-detail="id !== 'add'"
- @selectChange="selectAreaorigin_place"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12" style="padding: 0 0 0 15px">
- <el-table
- :data="spec_tableData"
- :size="'mini'"
- border
- style="width: 100%"
- max-height="120px"
- >
- <el-table-column prop="spec_name" label="规格类型" />
- <el-table-column prop="spec_value_name" label="规格值" />
- <el-table-column
- fixed="right"
- width="88px"
- v-if="type !== 'view'"
- >
- <template slot="header" slot-scope="scope">
- <span>操作</span>
- <el-tooltip
- class="item"
- effect="dark"
- content="添加规格类型"
- placement="top"
- >
- <i
- class="el-icon-circle-plus-outline fr"
- style="font-size: 18px; margin-top: 2px"
- @click="openEdit('-1', {})"
- />
- </el-tooltip>
- </template>
- <template slot-scope="scope">
- <el-tooltip effect="dark" content="修改" placement="top">
- <i
- class="el-icon-edit tb-icon"
- @click="openEdit(scope.$index, scope.row)"
- ></i>
- </el-tooltip>
- <el-tooltip effect="dark" content="删除" placement="top">
- <i
- class="el-icon-delete tb-icon"
- @click="openDelete(scope.$index)"
- ></i>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- <!-- 弹窗 新增/修改 -->
- <base-form-add-edit
- :index="modelIndex"
- :show-model="showOtherModel"
- :sitem="modelSitem"
- @refresh="refreshEdit"
- @cancel="showOtherModel = false"
- />
- </el-col>
- </el-row>
- </el-col>
- <el-col :span="6">
- <el-form-item label="总重量" prop="weight">
- <digital-input
- :values="ruleForm.weight"
- :placeholder="'总重量'"
- :min="0"
- :max="100000000000"
- :position="'right'"
- :precision="3"
- :disabled="type === 'view'"
- :size="'mini'"
- :controls="false"
- :append="'g'"
- @reschange="number_change($event, 'weight')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="供货区域" prop="supply_area">
- <el-select
- v-model="ruleForm.supply_area"
- filterable
- :disabled="type === 'view'"
- clearable
- style="width: 100%"
- placeholder="供货区域"
- >
- <el-option
- v-for="group in options6"
- :key="group.id"
- :label="group.name"
- :value="group.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="付款方式" prop="pay_way" class="clear">
- <el-select
- v-model="ruleForm.pay_way"
- filterable
- :disabled="type === 'view'"
- clearable
- style="width: 100%"
- placeholder="付款方式"
- >
- <el-option
- v-for="group in options10"
- :key="group.id"
- :label="group.name"
- :value="group.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="发货方式" prop="send_way" class="clear">
- <el-select
- v-model="ruleForm.send_way"
- filterable
- clearable
- :disabled="type === 'view'"
- style="width: 100%"
- placeholder="发货方式"
- >
- <el-option
- v-for="group in options11"
- :key="group.id"
- :label="group.name"
- :value="group.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="证书费" prop="cert_fee">
- <digital-input
- :values="ruleForm.cert_fee"
- :placeholder="'证书费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'cert_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="包装费" prop="pakge_fee">
- <digital-input
- :values="ruleForm.pakge_fee"
- :placeholder="'包装费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'pakge_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="工艺费" prop="cost_fee">
- <digital-input
- :values="ruleForm.pcost_fee"
- :placeholder="'工艺费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'cost_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="加标费" prop="mark_fee">
- <digital-input
- :values="ruleForm.mark_fee"
- :placeholder="'加标费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'mark_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="打样费" prop="demo_fee">
- <digital-input
- :values="ruleForm.demo_fee"
- :placeholder="'打样费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'demo_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="开模费" prop="open_fee">
- <digital-input
- :values="ruleForm.open_fee"
- :placeholder="'开模费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'open_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="物流费" prop="delivery_fee">
- <digital-input
- :values="ruleForm.delivery_fee"
- :placeholder="'物流费'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'delivery_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="裸价" prop="nake_fee" class="clear">
- <digital-input
- :values="ruleForm.nake_fee"
- :placeholder="'裸价'"
- :min="0"
- :disabled="type === 'view' || is_noble"
- :max="100000000000"
- :position="'right'"
- :precision="2"
- :size="'mini'"
- :controls="false"
- :append="'元'"
- @reschange="number_change($event, 'nake_fee')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="24" v-show="is_noble">
- <el-col :span="6">
- <el-form-item label="金属重量" prop="noble_weight">
- <digital-input
- :values="ruleForm.noble_weight"
- :placeholder="'金属重量'"
- :min="0"
- :disabled="type === 'view'"
- :max="100000000000"
- :position="'right'"
- :precision="3"
- :size="'mini'"
- :controls="false"
- :append="'g'"
- @reschange="number_change($event, 'noble_weight')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="金属种类" prop="metal_id">
- <search-metal-kind
- :value="ruleForm.metal_id"
- :size="'mini'"
- :disabled="false"
- :isDetail="true"
- :placeholder="'金属种类'"
- @searchChange="metal_idsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="启用金价" prop="is_gold_price">
- <el-select
- v-model="ruleForm.is_gold_price"
- filterable
- clearable
- :disabled="type === 'view'"
- style="width: 100%"
- placeholder="启用金价"
- >
- <el-option
- v-for="group in options5"
- :key="group.id"
- :label="group.name"
- :value="group.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="有无工差" prop="is_diff">
- <el-select
- v-model="ruleForm.is_diff"
- filterable
- clearable
- :disabled="type === 'view'"
- style="width: 100%"
- placeholder="有无工差"
- >
- <el-option
- v-for="group in options8"
- :key="group.id"
- :label="group.name"
- :value="group.id"
- />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="配置要求" prop="config">
- <el-select
- v-model="ruleForm.config"
- multiple
- :disabled="type === 'view'"
- style="width: 100%"
- placeholder="配置要求"
- >
- <el-option
- v-for="(item, index) in options9"
- :key="item + index"
- :label="item"
- :value="item"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="其他配置要求"
- prop="other_config"
- label-width="120px"
- >
- <el-input
- placeholder="其他要求"
- maxlength="100"
- :disabled="type === 'view'"
- v-model="ruleForm.other_config"
- >
- </el-input>
- </el-form-item>
- </el-col>
- </el-col>
- <el-col :span="18">
- <el-form-item label="采购备注" prop="remark">
- <el-input
- placeholder="采购备注"
- maxlength="500"
- :disabled="type === 'view'"
- v-model="ruleForm.remark"
- >
- </el-input>
- </el-form-item>
- <el-form-item label="工艺说明" prop="cost_desc">
- <el-input
- placeholder="工艺说明"
- maxlength="500"
- :disabled="type === 'view'"
- v-model="ruleForm.cost_desc"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item
- label="商品图片(<1mb)"
- prop="good_img"
- class="activity-upload"
- >
- <div class="btnupload" style="position: relative">
- <img
- v-if="ruleForm.good_img"
- :src="ruleForm.good_img"
- class="avatar"
- />
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- <file-upload
- class="Upload"
- :accept="'.jpg,.png,.jpeg'"
- :multiple="true"
- :disabled="type === 'view'"
- :uploadcondition="beforeAvatarUpload"
- @UploadErrorEvent="UploadErrorEventgood_img"
- @UploadSuccessEvent="UploadSuccessEventgood_img"
- ></file-upload>
- </div>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </template>
- <script>
- import asyncRequest from "@/apis/service/purchaseIn/workbench";
- import resToken from "@/mixins/resToken";
- import { mapGetters } from "vuex";
- import baseFormAddEdit from "./baseFormAddEdit";
- import {
- options1,
- options2,
- options3,
- options4,
- options5,
- options6,
- options7,
- options8,
- options9,
- options10,
- options11,
- rules,
- } from "../columns";
- export default {
- name: "goodsCostAdd",
- mixins: [resToken],
- props: ["showModel", "id", "type", "sitem", "askItem", "newTime", "editId",],
- components: {
- baseFormAddEdit,
- },
- computed: {
- ...mapGetters(["tablebtnSize", "searchSize", "size"]),
- powers() {
- let tran =
- this.$store.getters.btnList.find(
- (item) => item.menu_route == "goodsCostAdd"
- ) || {};
- if (tran && tran.action && tran.action.length > 0) {
- return tran.action;
- } else {
- return [];
- }
- },
- },
- watch: {
- newTime: function (val) {
- if (val) {
- this.initForm();
- }
- },
- },
- data() {
- return {
- cat_id_name: "",
- supplierNo: "",
- brand_name: "",
- unit_name: "",
- title: "",
- modelIndex: "",
- modelSitem: {},
- showOtherModel: false,
- is_noble: false,
- status: "",
- rulesThis: this.rules,
- activeName: "1",
- loading: true,
- options1: options1,
- options2: options2,
- options3: options3,
- options4: options4,
- options5: options5,
- options6: options6,
- options7: options7,
- options8: options8,
- options9: options9,
- options10: options10,
- options11: options11,
- ruleForm: {},
- rules: JSON.parse(JSON.stringify(rules)),
- r1:"",
- r2:"",
- };
- },
- mounted() {
- this.initForm();
- this.$nextTick(()=>{
- this.r1 = this.accMul(this.ruleForm.noble_weight,this.askItem.gold_price)
- this.r2 = this.accMul(this.ruleForm.cost_fee,this.ruleForm.noble_weight)
- console.log(this.r1,this.r2)
- })
-
-
- },
- methods: {
- //加法精度问题
- // accAdd(arg1,arg2){
- // var r1,r2,m;
- // try{
- // r1=arg1.toString().split(".")[1].length;
- // }catch(e){
- // r1=0;
- // }
- // try{
- // r2=arg2.toString().split(".")[1].length;
- // }catch(e){
- // r2=0;
- // }
- // m=Math.pow(10,Math.max(r1,r2)) ;
- // return (arg1*m+arg2*m)/m ;
- // },
- accAdd(arg1,arg2,arg3,arg4,arg5,arg6,arg7){
- var r1,r2,r3,r4,r5,r6,r7,m;
- console.log(arg1,arg2,arg3,arg4,arg5,arg6,arg7)
- try{
- r1=arg1.toString().split(".")[1].length;
- }catch(e){
- r1=0;
- }
- try{
- r2=arg2.toString().split(".")[1].length;
- }catch(e){
- r2=0;
- }
- try{
- r3=arg3.toString().split(".")[1].length;
- }catch(e){
- r3=0;
- }
- try{
- r4=arg4.toString().split(".")[1].length;
- }catch(e){
- r4=0;
- }
- try{
- r5=arg5.toString().split(".")[1].length;
- }catch(e){
- r5=0;
- }
- try{
- r6=arg6.toString().split(".")[1].length;
- }catch(e){
- r6=0;
- }
- try{
- r7=arg7.toString().split(".")[1].length;
- }catch(e){
- r7=0;
- }
- m=Math.pow(10,Math.max(r1,r2,r3,r4,r5,r6,r7)) ;
- return (arg1*m+arg2*m+arg3*m+arg4*m+arg5*m+arg6*m+arg7*m)/m ;
- },
- //乘法精度问题
- accMul(arg1, arg2) {
- var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
- try {
- m += s1.split(".")[1].length;
- }
- catch (e) {
- }
- try {
- m += s2.split(".")[1].length;
- }
- catch (e) {
- }
- let numStr = Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
- return numStr.toString()
- },
- async initForm() {
- this.supplierNo = [];
- console.log(this.id);
- this.loading = true;
- if (this.type === "add") {
- this.title = "新建采返商品";
- } else if (this.type === "edit") {
- this.title = "编辑采返商品";
- } else {
- this.title = "采返商品详情";
- }
- console.log(this.type);
- this.resetFormData();
- this.rulesThis = this.rules;
- await this.resetForm();
- if (this.type === "edit" || this.type === "view") {
- await this.initData();
- }
- this.setrules();
- this.loading = false;
- },
- number_change(e, key) {
- this.ruleForm[key] = e + "" || "0";
- this.$refs.ruleForm.validateField(key);
- this.$nextTick(()=>{
- this.r1 = this.accMul(this.ruleForm.noble_weight,this.askItem.gold_price)
- this.r2 = this.accMul(this.ruleForm.cost_fee,this.ruleForm.noble_weight)
- })
- },
- async initData() {
- this.loading = true;
- const { code, message, data } = await asyncRequest.good_detail({
- bidNo: this.editId,
- });
- console.log(data);
- if (code === 0) {
- const {
- bidNo,
- good_name, //string 名称
- cat_id, //array 分类
- cat_info,
- brand_id, //string 品牌id
- unit, // string 单位
- unit_id, //单位ID
- tax, //string 税率
- supplierNo, // string 供应商
- cost_desc, // string 工艺说明
- remark, // string 采购备注
- weight, // string 重量
- supply_area, // string 供货区域 1 全国2 除偏远地区
- origin_place, // string 产地
- delivery_day, // string 物流天数
- expire_day, // string 信息有效期
- good_img, //
- // good_name,
- cert_fee, // string 证书费
- pakge_fee, // string 打包费
- cost_fee, // string 工艺费
- mark_fee, // string 加标费
- demo_fee, // string 打样费
- open_fee, // string 开模费
- metal_id, // string 金属类别
- noble_weight, // string 金属重量
- is_gold_price, // string 是否使用实时金价
- delivery_fee, // string 物流费
- status, // string 状态
- brand_name,
- work_day,
- pay_way,
- send_way,
- is_diff,
- config,
- nake_fee,
- other_config,
- supplierName,
- specinfo,
- } = JSON.parse(JSON.stringify(data));
- if (specinfo && specinfo.length > 0) {
- this.spec_tableData = JSON.parse(JSON.stringify(specinfo));
- }
- this.cat_id_name = "";
- if (cat_info && cat_info.length) {
- cat_info.forEach((e, ei) => {
- this.cat_id_name += `${ei !== 0 ? "_" : ""}${e.name}`;
- });
- }
- this.supplierNo_name = supplierName || "";
- console.log(this.supplierNo_name);
- this.is_noble = this.askItem.is_metal;
- this.brand_name = brand_name || "";
- this.unit_name = unit || "";
- this.ruleForm = {
- infoNo: this.id || "",
- bidNo: bidNo || "",
- infoNo: this.id || "",
- cat_id: cat_id ? [cat_id] : [],
- supplierNo: supplierNo ? [supplierNo] : [],
- pname: good_name || "",
- expire_day: expire_day || "0", //有效期
- delivery_day: delivery_day || "0", //物流时间
- work_day: work_day || "0", //生产工期
- brandid: brand_id ? [brand_id] : [],
- unit_id: unit_id ? [unit_id] : [],
- weight: weight || "0.000",
- tax: tax ? tax + "%" : "",
- supply_area: supply_area || "",
- origin_place: origin_place ? origin_place.split(",") : [],
- cert_fee: cert_fee || "0.00",
- pakge_fee: pakge_fee || "0.00",
- cost_fee: cost_fee || "0.00",
- mark_fee: mark_fee || "0.00",
- demo_fee: demo_fee || "0.00",
- open_fee: open_fee || "0.00",
- delivery_fee: delivery_fee || "0.00",
- nake_fee: nake_fee || "0.00",
- pay_way: pay_way || "",
- send_way: send_way || "",
- noble_weight: noble_weight || "0.000",
- metal_id: metal_id || "",
- is_gold_price: is_gold_price || "",
- is_diff: is_diff || "",
- config: config ? config.split(",") : [],
- other_config: other_config || "",
- remark: remark || "",
- cost_desc: cost_desc || "",
- good_img: good_img || "",
- };
- this.status = status;
- if (this.is_noble) {
- this.ruleForm.nake_fee = "0";
- }
- // console.log(this.ruleForm.origin_place);
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- }
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- if (this.spec_tableData.length === 0) {
- this.$message.warning("请填写规格!");
- this.loading = false;
- return;
- }
- let model = JSON.parse(JSON.stringify(this.ruleForm));
- model.cat_id = model.cat_id[model.cat_id.length - 1];
- model.brandid = model.brandid.toString();
- model.supplierNo = model.supplierNo.toString();
- model.origin_place = model.origin_place.toString();
- model.unit_id = model.unit_id.toString();
- model.config = model.config.toString();
- model.tax = parseInt(model.tax + "") + "";
- model.specinfo = [];
- let list = JSON.parse(JSON.stringify(this.spec_tableData));
- list.forEach((a) => {
- let am = {
- specid: a.specid,
- spec_value_id: a.spec_value_id,
- };
- model.specinfo.push(am);
- });
- console.log(model);
- let res = {};
- if (this.type === "add") {
- delete model["bidNo"];
- res = await asyncRequest.good_add(model);
- } else {
- res = await asyncRequest.good_update(model);
- }
- console.log(res);
- this.loading = false;
- if (res && res.code === 0) {
- const title = this.type === "add" ? "新建成功!" : "修改成功!";
- this.$notify.success({
- title: title,
- message: "",
- });
- this.showModelThis = false;
- // 刷新
- this.$emit("refresh");
- } else if (res && res.code >= 100 && res.code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(res.message);
- }
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- async resetForm() {
- // 重置
- await this.$nextTick(async () => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- this.spec_tableData = [];
- console.log(this.askItem);
- // const { can_id_arr } = this.askItem;
- this.is_noble = this.askItem.is_metal;
- this.cat_id_name = this.type === "add" ? this.askItem.can_name : "";
- this.brand_name =""
- // this.type === "add" ? this.askItem.brand : "";
- this.unit_name = ""
- //this.type === "add" ? this.askItem.unit_name : "";
- this.ruleForm = {
- infoNo: this.id || "",
- cat_id: this.type === "add" ? [this.askItem.cat_id] : [],
- supplierNo: [],
- pname: this.type === "add" ? this.askItem.good_name : "",
- expire_day: "0", //有效期
- delivery_day: "0", //物流时间
- work_day: "0", //生产工期
- brandid:[],
- // this.type === "add" && this.askItem.brand_id
- // ? [this.askItem.brand_id]
- // : [],
- unit_id: [],
- //this.type === "add" ? [this.askItem.unit] : [],
- weight: this.type === "add" ? this.askItem.total_weight : "0.000",
- tax: "",
- supply_area: "",
- origin_place: [],
- cert_fee: "0.00",
- pakge_fee: "0.00",
- cost_fee: "0.00",
- mark_fee: "0.00",
- demo_fee: "0.00",
- open_fee: "0.00",
- delivery_fee: "0.00",
- nake_fee: "0.00",
- pay_way: "",
- send_way: "",
- noble_weight:
- this.type === "add" ? this.askItem.specs_weight : "0.000",
- metal_id: this.type === "add" ? this.askItem.metal_id : "",
- is_gold_price:
- this.type === "add" ? this.askItem.is_gold_price : "",
- is_diff: "",
- config:
- this.type === "add"
- ? this.askItem.config
- ? this.askItem.config.split(",")
- : []
- : [],
- other_config: this.type === "add" ? this.askItem.other_config : "",
- remark: "",
- cost_desc: this.type === "add" ? this.askItem.cost_desc : "",
- good_img: this.type === "add" ? this.askItem.good_img : "",
- };
- if (this.type === "add") {
- this.spec_tableData = JSON.parse(
- JSON.stringify(this.askItem.specinfo)
- );
- }
- }
- });
- },
- openEdit(index, sitem) {
- this.modelIndex = index;
- this.modelSitem = sitem;
- this.showOtherModel = true;
- },
- openDelete(index) {
- this.spec_tableData.splice(index, 1);
- },
- //规格编辑修改结果
- refreshEdit(e) {
- let item = JSON.parse(JSON.stringify(e));
- const { index, specid, spec_name, spec_value_id, spec_value_name } = item;
- if (index + "" === "-1") {
- this.spec_tableData.push(item);
- } else {
- let findex = parseInt(index + "");
- this.spec_tableData[findex].specid = specid;
- this.spec_tableData[findex].spec_name = spec_name;
- this.spec_tableData[findex].spec_value_id = spec_value_id;
- this.spec_tableData[findex].spec_value_name = spec_value_name;
- }
- this.showOtherModel = false;
- },
- //分类选择
- async cat_id_change(e) {
- const { pid, id, label } = e;
- this.ruleForm.cat_id = id ? [id] : [];
- this.is_noble = pid === "6";
- this.$refs.ruleForm.validateField("cat_id");
- this.setrules();
- this.ruleForm.nake_fee = "0";
- },
- setrules() {
- let list = [
- "noble_weight",
- "metal_id",
- "is_gold_price",
- "is_diff",
- "config",
- "other_config",
- ];
- for (let i = 0; i < list.length; i++) {
- this.rules[list[i]][0].required = this.is_noble;
- }
- },
- //品牌选择
- brandidsearchChange(e) {
- const { id, code, label } = e;
- if (id) {
- this.ruleForm.brandid = [id];
- } else {
- this.ruleForm.brandid = [];
- }
- this.$refs.ruleForm.validateField("brandid");
- },
- //供应商选择
- supplierNosearchChange(e) {
- console.log(e);
- const { id, code, label } = e;
- if (id) {
- this.ruleForm.supplierNo = [code];
- } else {
- this.ruleForm.supplierNo = [];
- }
- this.$refs.ruleForm.validateField("supplierNo");
- },
- //税点选择
- taxsearchChange(e) {
- this.ruleForm.tax = e;
- this.$refs.ruleForm.validateField("tax");
- },
- //单位选择
- unitsearchChange(e) {
- const { id, code, label } = e;
- if (id) {
- this.ruleForm.unit_id = [code];
- } else {
- this.ruleForm.unit_id = [];
- }
- this.$refs.ruleForm.validateField("unit_id");
- },
- //金属种类选择
- metal_idsearchChange(e) {
- console.log(e);
- const { id, code, label } = e;
- if (id) {
- this.ruleForm.metal_id = id;
- } else {
- this.ruleForm.metal_id = "";
- }
- this.$refs.ruleForm.validateField("metal_id");
- },
- //仓库省市区
- selectAreaorigin_place(e) {
- this.ruleForm.origin_place = e;
- this.$refs.ruleForm.validateField("origin_place");
- },
- //图片上传成功
- async UploadSuccessEventgood_img(data) {
- await this.UploadSuccessEvent(1, data);
- },
- //图片上传成功
- async UploadSuccessEvent(type, data) {
- const { url } = data;
- if (url === "noToken") {
- await this.logout();
- } else {
- if (type === 1) {
- this.ruleForm.good_img = url;
- this.$refs.ruleForm.validateField("good_img");
- } else if (type === 2) {
- this.ruleForm.good_img = url;
- this.$refs.ruleForm.validateField("good_img");
- }
- this.$message.success("图片上传成功!");
- }
- },
- //图片上传失败
- UploadErrorEventgood_img(res) {
- this.imgUploadError(1, res);
- },
- imgUploadError(type, res) {
- if (res !== "break") {
- this.$message.error("图片上传失败!");
- this.$refs.ruleForm.validateField(
- type === 1 ? "good_img" : type === 2 ? "good_img" : ""
- );
- }
- },
- //判断图片规格
- beforeAvatarUpload(file) {
- let isJPG = false;
- if (
- file.type === "image/jpg" ||
- file.type === "image/png" ||
- file.type === "image/jpeg"
- ) {
- isJPG = true;
- }
- const isLt2M = file.size / 1024 / 1024 < 1;
- if (!isJPG) {
- this.$message.error("图片格式不正确!");
- }
- if (!isLt2M) {
- this.$message.error("图片大小不能超过 1MB!");
- }
- return isJPG && isLt2M;
- },
- resetFormData() {
- this.status = "";
- this.is_noble = false;
- this.cat_id_name = "";
- this.brand_name = "";
- this.unit_name = "";
- this.ruleForm = {
- infoNo: "",
- cat_id: [],
- supplierNo: [],
- pname: "",
- expire_day: "0", //有效期
- delivery_day: "0", //物流时间
- work_day: "0", //生产工期
- color: "",
- model: "",
- material: "",
- brandid: [],
- unit_id: [],
- weight: "0.000",
- tax: "",
- supply_area: "",
- origin_place: [],
- cert_fee: "0.00",
- pakge_fee: "0.00",
- cost_fee: "0.00",
- mark_fee: "0.00",
- demo_fee: "0.00",
- open_fee: "0.00",
- delivery_fee: "0.00",
- nake_fee: "0.00",
- pay_way: "",
- send_way: "",
- noble_weight: "0.000",
- metal_id: "",
- is_gold_price: "",
- is_diff: "",
- config: [],
- other_config: "",
- remark: "",
- cost_desc: "",
- good_img: "",
- };
- },
- addFormData() {
- this.status = "";
- this.is_noble = false;
- this.cat_id_name = "";
- this.brand_name = "";
- this.unit_name = "";
- this.ruleForm = {
- infoNo: "",
- cat_id: [],
- supplierNo: [],
- pname: "",
- expire_day: "0", //有效期
- delivery_day: "0", //物流时间
- work_day: "0", //生产工期
- color: "",
- model: "",
- material: "",
- brandid: [],
- unit_id: [],
- weight: "0.000",
- tax: "",
- supply_area: "",
- origin_place: [],
- cert_fee: "0.00",
- pakge_fee: "0.00",
- cost_fee: "0.00",
- mark_fee: "0.00",
- demo_fee: "0.00",
- open_fee: "0.00",
- delivery_fee: "0.00",
- nake_fee: "0.00",
- pay_way: "",
- send_way: "",
- noble_weight: "0.000",
- metal_id: "",
- is_gold_price: "",
- is_diff: "",
- config: [],
- other_config: "",
- remark: "",
- cost_desc: "",
- good_img: "",
- };
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .goodsCostDetail {
- .goodsCostAdd-title {
- border-top: 1px solid #ebeef5;
- span {
- height: 50px;
- line-height: 50px;
- font-family: "微软雅黑", sans-serif;
- font-weight: 400;
- font-style: normal;
- font-size: 16px;
- text-align: left;
- }
- }
- }
- </style>
-
|