| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055 |
- <template>
- <div class="ele-body">
- <el-tabs v-model="activeTab" type="card" class="product-detail-tabs">
- <el-tab-pane label="详情" name="detail">
- <el-card shadow="never">
- <el-form
- label-width="100px"
- ref="manageForm"
- :model="form"
- :rules="rules"
- >
- <headerTitle title="基本信息">
- <el-button @click="cancel">返回</el-button>
- <el-button
- v-if="!isReadOnly"
- type="primary"
- @click="submit"
- :loading="loading"
- >保存
- </el-button>
- </headerTitle>
- <el-row :gutter="24">
- <el-col :span="8">
- <el-form-item label="分类" prop="categoryLevelName">
- <el-input
- v-model="form.categoryLevelName"
- @click.native="openCategory"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="编码" prop="code">
- <!-- <el-input
- v-if="ruleCode == '自定义'"
- v-model="form.code"
- readonly
- @click.native="openCode"
- :disabled="status == 0"
- /> -->
- <el-input
- v-model="form.code"
- :disabled="status == 0 || isReadOnly"
- >
- <template slot="append" v-if="status != 0 && !isReadOnly">
- <el-link :underline="false" @click.native="getCodeOpen"
- >申请编码
- </el-link></template
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="名称" prop="name">
- <el-input v-model="form.name" :disabled="isReadOnly" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="存货类型:" prop="attributeType">
- <!-- <DictSelection
- dictName="存货类型"
- clearable
- v-model="form.attributeType"
- >
- </DictSelection> -->
- <el-select
- v-model="form.attributeType"
- filterable
- class="ele-block"
- :disabled="isReadOnly"
- >
- <el-option
- v-for="item in attributeList"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <div>
- <el-form-item label="属性类型" prop="componentAttribute">
- <el-select
- style="width: 100%"
- v-model="form.componentAttribute"
- filterable
- multiple
- :disabled="isReadOnly"
- >
- <el-option
- v-for="item in lbjtList"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- ></el-option>
- </el-select>
- </el-form-item>
- </div>
- </el-col>
- <el-col :span="8">
- <div>
- <el-form-item
- label="生产类型"
- prop="produceType"
- :rules="{
- required:
- form.categoryLevelPathId.substring(0, 1) == 9 ||
- form.componentAttribute.includes(1) == 1
- ? true
- : false,
- message: '请选择生产类型',
- trigger: 'change'
- }"
- >
- <el-select
- style="width: 100%"
- v-model="form.produceType"
- filterable
- @change="produceTypeChange"
- :disabled="isReadOnly"
- >
- <el-option
- v-for="item in produceTypeList"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- ></el-option>
- </el-select>
- </el-form-item>
- </div>
- </el-col>
- <el-col :span="8">
- <!-- v-if="
- [1, 23, 9, 28].includes(
- Number(categoryLevelPathId || $route.query.rootTreeId)
- )
- " -->
- <el-form-item
- label="加工类型"
- prop="isConsumable"
- :rules="{
- required: mandatoryFieldList.includes('isConsumable'),
- message: '请选择加工类型',
- trigger: 'change'
- }"
- >
- <el-select
- v-model="form.isConsumable"
- style="width: 100%"
- @change="changeConsumable"
- :disabled="isReadOnly"
- >
- <el-option :value="1" label="批量"></el-option>
- <el-option :value="0" label="单件"></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="牌号"
- prop="brandNum"
- :rules="{
- required: mandatoryFieldList.includes('brandNum'),
- message: '请输入牌号',
- trigger: 'change'
- }"
- >
- <el-input v-model="form.brandNum" :disabled="isReadOnly" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="型号"
- prop="modelType"
- :rules="{
- required: mandatoryFieldList.includes('modelType'),
- message: '请输入型号',
- trigger: 'change'
- }"
- >
- <el-input v-model="form.modelType" :disabled="isReadOnly" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="规格"
- prop="specification"
- :rules="{
- required: mandatoryFieldList.includes('specification'),
- message: '请输入规格',
- trigger: 'change'
- }"
- >
- <el-input
- v-model="form.specification"
- @input="inputSpe"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="计量类型"
- prop="measureType"
- :rules="{
- required: mandatoryFieldList.includes('measureType'),
- message: '请选择计量类型',
- trigger: 'change'
- }"
- >
- <el-select
- v-model="form.measureType"
- style="width: 100%"
- @change="changeMeasureType"
- :disabled="isReadOnly"
- >
- <el-option
- v-for="item in measureTypeList"
- :key="item.value"
- :value="item.value"
- :label="item.label"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="计量单位" prop="measuringUnit">
- <DictSelection
- dictName="计量单位"
- clearable
- v-model="form.measuringUnit"
- @change="changeUnit"
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="重量单位" prop="weightUnit">
- <DictSelection
- dictName="重量单位"
- clearable
- v-model="form.weightUnit"
- @change="changeWeightUnit"
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="包装单位" prop="packingUnit">
- <DictSelection
- dictName="包装单位"
- clearable
- v-model="form.packingUnit"
- @change="changeUnit"
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="面积" prop="area">
- <el-input
- v-model="form.area"
- @input="handleAreaInput"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="面积单位" prop="areaUnit">
- <DictSelection
- dictName="计量单位"
- clearable
- v-model="form.areaUnit"
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="图号/件号"
- prop="imgCode"
- :rules="{
- required: mandatoryFieldList.includes('imgCode'),
- message: '请输入图号/件号',
- trigger: 'change'
- }"
- >
- <el-input v-model="form.imgCode" :disabled="isReadOnly" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="毛重"
- prop="roughWeight"
- :rules="{
- required: mandatoryFieldList.includes('roughWeight'),
- message: '请输入毛重',
- trigger: 'change'
- }"
- >
- <div class="form-line">
- <el-input
- v-model="form.roughWeight"
- @input="handleInput2"
- :disabled="isReadOnly"
- />
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <!-- 计量类型为重量 净重必填 -->
- <el-form-item
- label="净重"
- prop="netWeight"
- :rules="{
- required: form.measureType == 2,
- trigger: ['blur', 'change'],
- message: '请输入净重'
- }"
- >
- <div class="form-line">
- <el-input
- v-model="form.netWeight"
- @input="handleInput3"
- :disabled="isReadOnly"
- />
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="体积"
- prop="volume"
- :rules="{
- required: mandatoryFieldList.includes('volume'),
- message: '请输入体积',
- trigger: 'change'
- }"
- >
- <div class="form-line">
- <el-input
- v-model="form.volume"
- @input="handleInput"
- style="width: calc(100% - 100px)"
- :disabled="isReadOnly"
- />
- <DictSelection
- dictName="体积单位"
- clearable
- v-model="form.volumeUnit"
- style="width: 100px"
- :disabled="isReadOnly"
- >
- </DictSelection>
- </div>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="级别"
- prop="level"
- :rules="{
- required: mandatoryFieldList.includes('level'),
- message: '请选择级别',
- trigger: 'change'
- }"
- >
- <template>
- <el-select
- style="width: 100%"
- v-model="form.level"
- placeholder="请选择"
- @change="levelChange"
- :disabled="isReadOnly"
- >
- <el-option
- v-for="item in levelOptions"
- :label="item.label"
- :value="item.value"
- :key="item.value"
- >
- </el-option>
- </el-select>
- </template>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="机型"
- prop="modelKey"
- :rules="{
- required: mandatoryFieldList.includes('modelKey'),
- message: '请选择机型',
- trigger: 'change'
- }"
- >
- <DictSelection
- dictName="物品机型"
- clearable
- v-model="form.modelKey"
- multiple
- filterable
- allow-create
- default-first-option
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item
- label="颜色"
- prop="colorKey"
- :rules="{
- required: mandatoryFieldList.includes('colorKey'),
- message: '请选择颜色',
- trigger: 'change'
- }"
- >
- <DictSelection
- dictName="物品颜色"
- clearable
- v-model="form.colorKey"
- multiple
- filterable
- allow-create
- default-first-option
- :disabled="isReadOnly"
- >
- </DictSelection>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="状态">
- <template>
- <el-switch
- v-model="form.isEnabled"
- :active-text="form.isEnabled == 1 ? '启用' : '停用'"
- :active-value="1"
- :inactive-value="0"
- :disabled="isReadOnly"
- >
- </el-switch>
- </template>
- </el-form-item>
- </el-col>
- <!-- :rules="{
- required:
- form.categoryLevelPathId.substring(0, 1) == 9 ||
- form.componentAttribute.includes(1) == 1
- ? true
- : false,
- message: '请选择生产类型',
- trigger: 'change'
- }" -->
- <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
- <el-form-item
- :label="f.label"
- :prop="'extField.' + f.prop"
- :rules="{
- required: mandatoryFieldList.includes(f.prop),
- message: '请输入',
- trigger: 'change'
- }"
- >
- <template>
- <div class="form-line">
- <component
- :is="f.tagType"
- v-model="form.extField[f.prop]"
- :disabled="f.extAttribute?.disabled || isReadOnly"
- clearable
- :isProhibit="
- f.modelType == 'dict'
- ? f.extAttribute?.disabled || isReadOnly
- : false
- "
- :dictName="f.modelType == 'dict' ? f.label : ''"
- ></component>
- </div>
- </template>
- </el-form-item>
- </el-col>
- <template v-if="industryAttribute == 1">
- <el-col :span="8">
- <el-form-item label="性味与归经">
- <el-input
- v-model="form.propertiesChannelTropism"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="功能与主治">
- <el-input
- v-model="form.actionsAndUses"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="用法与用量">
- <el-input
- v-model="form.usageAndDosage"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- </template>
- <el-col :span="8" v-if="clientEnvironmentId == 5">
- <el-form-item label="需要序列号">
- <el-radio-group
- v-model="form.extTagField.needProductSequence"
- :disabled="isReadOnly"
- >
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="物联产品Key">
- <el-input v-model="form.iotProductKey" :disabled="isReadOnly" />
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <el-form-item label="产品图片">
- <ImgUpload
- ref="imgUploadRef"
- v-model="form.imgUrl"
- :disabled="isReadOnly"
- />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </el-card>
- <el-card shadow="never">
- <headerTitle title="标签"></headerTitle>
- <!-- {{ form.extTagField }} -->
- <el-form label-width="100px">
- <el-form-item label="是否消耗品">
- <el-radio-group
- v-model="form.extTagField.isConsumables"
- :disabled="isReadOnly"
- >
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- </el-form>
- </el-card>
- <!-- 自定义编码 -->
- <!-- <CodeDialog
- ref="codeRefs"
- v-if="codeShow"
- @close="codeShow = false"
- @chooseCode="chooseCode"
- /> -->
- <!-- 分类选择弹窗 -->
- <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
- <!-- 仓储配置 -->
- <WarehouseInfo
- ref="warehouseRefs"
- v-if="isShow"
- :form="categoryWms"
- :measuringUnit="form.measuringUnit"
- :packingUnit="form.packingUnit"
- :packageDispositionVOList="packageDispositionVOList"
- :industry-attribute="industryAttribute"
- @change="changePackagingSpecification"
- :disabled="isReadOnly"
- />
- <!-- 销售配置 -->
- <SalesInfos ref="salesRefs" :form="categorySales" :disabled="isReadOnly" />
- <!-- 采购信息 -->
- <PurchasingInfo
- ref="PurchasingInfoRefs"
- :form="categoryPurchase"
- :industry-attribute="industryAttribute"
- :disabled="isReadOnly"
- />
- <!-- 生产信息 -->
- <ProductionInfo
- ref="productionRefs"
- :form="categoryMes"
- :disabled="isReadOnly"
- />
- <!-- 计划 -->
- <PlanInfo ref="planRefs" :form="categoryAps" :disabled="isReadOnly" />
- <!-- 质量配置 -->
- <QualityInfo ref="qualityRefs" :form="categoryQms" :disabled="isReadOnly" />
- <!-- 舟皿信息 -->
- <BoatInfo :form="categoryPallet" :disabled="isReadOnly" />
- <!-- 周转车信息 -->
- <TurnoverInfo
- ref="turnoverRefs"
- :form="categoryVehicle"
- :disabled="isReadOnly"
- />
- <!-- 模具信息 -->
- <MoldInfo ref="moldRefs" :form="categoryMold" :disabled="isReadOnly" />
- <!-- 备注信息 -->
- <RemarkInfo ref="remarkRefs" :form="remarkform" :disabled="isReadOnly" />
- <!-- 关联信息 -->
- <linkMsg
- ref="linkMsgRef"
- :id="$route.query.id"
- :categoryLevelId="form.categoryLevelId"
- :categoryLevelGroupId="form.categoryLevelGroupId"
- :code="form.code"
- :disabled="isReadOnly"
- />
- <!-- 申请编码 -->
- <GetCodeDialog ref="GetCodeDialogRef" @setCode="setCode"></GetCodeDialog>
- </el-tab-pane>
- <el-tab-pane v-if="hasProcessInstanceId" label="流程详情" name="bpm">
- <bpmDetail :id="form.processInstanceId"></bpmDetail>
- </el-tab-pane>
- </el-tabs>
- </div>
- </template>
- <script>
- import SalesInfos from './components/SalesInfos.vue';
- import PurchasingInfo from './components/PurchasingInfo.vue';
- import GroupDialog from './components/GroupDialog.vue';
- // import CodeDialog from './components/codeDialog.vue';
- import CategoryDialog from './components/CategoryDialog.vue';
- import WarehouseInfo from './components/WarehouseInfo.vue';
- import ProcureInfo from './components/ProcureInfo.vue';
- import ProductionInfo from './components/ProductionInfo.vue';
- import PlanInfo from './components/PlanInfo.vue';
- import SalesInfo from './components/SalesInfo.vue';
- import QualityInfo from './components/QualityInfo.vue';
- import BoatInfo from './components/BoatInfo.vue';
- import TurnoverInfo from './components/TurnoverInfo.vue';
- import MoldInfo from './components/MoldInfo.vue';
- import RemarkInfo from './components/RemarkInfo.vue';
- import deptSelect from '@/components/CommomSelect/dept-select.vue';
- import personSelect from '@/components/CommomSelect/person-select.vue';
- import linkMsg from './components/link-msg.vue';
- import { getDetails } from '@/api/classifyManage/itemInformation';
- import { getByCode } from '@/api/system/dictionary-data';
- import {
- getCode as getCodeApi,
- rootCategoryCode,
- fieldModel,
- checkExist
- } from '@/api/codeManagement';
- // /main/category/checkExist
- import { addMaterial } from '@/api/material/list.js';
- import { deepClone } from '@/utils/index';
- import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
- import { produceTypeList } from '@/enum/dict.js';
- import { copyObj } from '@/utils/util';
- import { parameterGetByCode } from '@/api/system/dictionary/index.js';
- import GetCodeDialog from '@/components/addDoc/getCode.vue';
- import { getCode, listCode } from '@/components/addDoc/api/index.js';
- import ImgUpload from '@/components/upload/imgUploadNew.vue';
- import bpmDetail from '@/views/bpm/processInstance/businessDetail.vue';
- const defCategoryQms = [
- {
- categoryId: '',
- checkDepart: null,
- sampleProportion: null,
- sampleProportionUnit: '%',
- checkPerson: null,
- checkProportion: null,
- createTime: '',
- createUserId: '',
- inspectionStandards: null,
- isComeCheck: 0,
- // level: '',
- levelItem: null,
- netWeight: null,
- qualityTemplateIds: [],
- dataType: 1
- },
- {
- categoryId: '',
- checkDepart: null,
- sampleProportion: null,
- sampleProportionUnit: '%',
- checkPerson: null,
- checkProportion: null,
- createTime: '',
- createUserId: '',
- inspectionStandards: null,
- isComeCheck: 0,
- // level: '',
- levelItem: null,
- netWeight: null,
- qualityTemplateIds: [],
- dataType: 2
- },
- {
- categoryId: '',
- checkDepart: null,
- sampleProportion: null,
- sampleProportionUnit: '%',
- checkPerson: null,
- checkProportion: null,
- createTime: '',
- createUserId: '',
- inspectionStandards: null,
- isComeCheck: 0,
- // level: '',
- levelItem: null,
- netWeight: null,
- qualityTemplateIds: [],
- dataType: 3
- }
- ];
- export default {
- name: 'product',
- components: {
- SalesInfos,
- PurchasingInfo,
- linkMsg,
- GroupDialog,
- deptSelect,
- personSelect,
- WarehouseInfo,
- ProcureInfo,
- ProductionInfo,
- PlanInfo,
- SalesInfo,
- QualityInfo,
- BoatInfo,
- TurnoverInfo,
- MoldInfo,
- RemarkInfo,
- CategoryDialog,
- // CodeDialog,
- GetCodeDialog,
- ImgUpload,
- bpmDetail
- },
- data() {
- return {
- activeTab: 'detail',
- isReadOnly: false,
- isShow: true,
- industryAttribute: '',
- produceTypeList,
- packagingSpecificationList: [],
- loading: false,
- productImgs: [],
- measureTypeList: [
- {
- label: '数量',
- value: 1
- },
- {
- label: '重量',
- value: 2
- },
- {
- label: '体积',
- value: 3
- },
- {
- label: '容积',
- value: 4
- },
- {
- label: '面积',
- value: 5
- }
- ],
- levelOptions: [
- {
- label: '特级',
- value: '特级'
- },
- {
- label: '一级',
- value: '一级'
- },
- {
- label: '二级',
- value: '二级'
- },
- {
- label: '三级',
- value: '三级'
- }
- ],
- isUpdate: 0,
- form: {
- categoryLevelGroupName: '',
- iotProductKey: '',
- imgUrl: [],
- propertiesChannelTropism: '',
- usageAndDosage: '',
- actionsAndUses: '',
- componentAttribute: [],
- categoryLevelName: '',
- isConsumable: 0,
- isEnabled: 1,
- measuringUnit: '',
- netWeight: '',
- attributeType: 1,
- weightUnit: '',
- packingUnit: '',
- areaUnit: '',
- area: '',
- colorKey: [],
- modelKey: [],
- extField: {},
- // isConsumables:2,
- extTagField: {
- isConsumables: 0,
- needProductSequence: 0
- }
- },
- lbjtList: [
- {
- label: '自制件',
- value: 1
- },
- {
- label: '采购件',
- value: 2
- },
- {
- label: '外协件',
- value: 3
- },
- {
- label: '受托件',
- value: 4
- }
- ],
- attributeList: [],
- remarkform: {
- remarkAttach: [],
- remark: ''
- },
- categorySales: {},
- categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
- categoryAps: {},
- categoryMes: { productionDays: '1' },
- categoryMold: {},
- categoryPallet: {},
- categoryQms: [...copyObj(defCategoryQms)],
- categoryVehicle: {},
- categoryWms: {
- isUnpack: 1,
- isWarn: 1,
- inventoryMode: '',
- secureInventory: '1',
- minInventory: '1',
- maxInventory: '1'
- },
- packageDispositionVOList: [],
- categoryLevelPathId: null,
- dictList: [
- {
- label: '加工',
- value: 1
- },
- {
- label: '装配',
- value: 3
- }
- ],
- fileList: [],
- // 表单验证规则
- PathInfo: {},
- id: null,
- ruleCode: null,
- codeShow: false,
- autoCodeRouteKey: '',
- status: null,
- isNetWeight: 0,
- mandatoryFieldList: []
- };
- },
- watch: {
- hasProcessInstanceId(value) {
- if (!value && this.activeTab === 'bpm') {
- this.activeTab = 'detail';
- }
- },
- '$route.query.id': {
- handler(id) {
- console.log(id, 'id');
- if (id) {
- this._getDetails();
- } else {
- let { lyType } = this.$route.query;
- let arrId = '';
- if (lyType == 'wp') {
- arrId = 3;
- }
- if (lyType == 'cp') {
- arrId = 1;
- }
- this.form = {
- categoryLevelGroupName: '',
- // categoryLevelName: '',
- componentAttribute: [],
- isConsumable: 0,
- attributeType: arrId,
- measuringUnit: '',
- netWeight: '',
- weightUnit: '',
- packingUnit: '',
- areaUnit: '',
- area: '',
- colorKey: [],
- modelKey: [],
- extField: {},
- extTagField: {
- isConsumables: 0,
- needProductSequence: 0
- },
- measureType: 1,
- isEnabled: 1
- };
- this.isUpdate = 0;
- this.categorySales = {};
- this.purchaseInfo = {};
- this.remarkform = {
- remarkAttach: [],
- remark: ''
- };
- this.categoryAps = {};
- this.categoryMes = {
- productionDays: '20',
- isCompleteSet: 0,
- isModify: 0,
- isRework: 0,
- isRematerial: 0,
- isByProduct: 0,
- isWaste: 0,
- isDefective: 0
- };
- this.categoryMold = {};
- this.categoryPallet = {};
- this.categoryQms = [...copyObj(defCategoryQms)];
- this.categoryVehicle = {};
- this.categoryWms = {
- isUnpack: 1,
- isWarn: 1,
- inventoryMode: this.form.isConsumable,
- minPackageCell: '',
- secureInventory: '10',
- minInventory: '10',
- maxInventory: '10'
- };
- this.packageDispositionVOList = [];
- this.categoryLevelPathId = null;
- // this.dictList = [];
- this.fileList = [];
- }
- },
- deep: true,
- immediate: true
- }
- // 同步图片id到表单模型(用于保存)
- // productImgs: {
- // handler(val) {
- // this.form.imgurl = val
- // .map((img) => img.id)
- // .filter(Boolean)
- // .join(',');
- // },
- // immediate: true
- // },
- },
- computed: {
- clientEnvironmentId() {
- return this.$store.state.user.info.clientEnvironmentId;
- },
- hasProcessInstanceId() {
- return (
- this.form.processInstanceId !== null &&
- this.form.processInstanceId !== undefined &&
- this.form.processInstanceId !== ''
- );
- },
- rules() {
- return {
- measureType: [
- { required: true, message: '请选择计量类型', trigger: 'change' }
- ],
- categoryLevelGroupName: [
- { required: true, message: '请选择所属物料组', trigger: 'change' }
- ],
- code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
- name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
- specification: [
- {
- required: this.clientEnvironmentId == 10 ? true : false,
- message: '请输入规格',
- trigger: 'blur'
- }
- ],
- modelType: [
- {
- required: this.clientEnvironmentId == 10 ? true : false,
- message: '请输入型号',
- trigger: 'blur'
- }
- ],
- 'extField.layBy': [
- {
- required: this.clientEnvironmentId == 10 ? true : false,
- message: '请输入贮藏',
- trigger: 'blur'
- }
- ],
- componentAttribute: [
- { required: true, message: '请选择属性类型', trigger: 'change' }
- ],
- attributeType: [
- { required: true, message: '请选择属性类型', trigger: 'change' }
- ],
- categoryLevelName: [
- { required: true, message: '请选择所属分类', trigger: 'change' }
- ],
- measuringUnit: [
- { required: true, message: '请选择计量单位', trigger: 'change' }
- ],
- weightUnit: [
- { required: true, message: '请选择重量单位', trigger: 'change' }
- ],
- packingUnit: [
- { required: true, message: '请选择包装单位', trigger: 'change' }
- ],
- netWeight: [
- { required: true, message: '请输入净重', trigger: 'blur' }
- ]
- };
- }
- },
- async activated() {
- this.status = this.$route.query.status;
- this.isReadOnly =
- this.$route.query.readOnly === 'true' ||
- this.$route.query.readOnly === true;
- console.log(
- 'activated - isReadOnly 状态:',
- this.isReadOnly,
- 'readOnly参数:',
- this.$route.query.readOnly
- );
- this.form.categoryLevelId = this.$route.query.categoryLevelId;
- this.form.categoryLevelName = this.$route.query.categoryLevelName;
- this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
- this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
- this.ruleCode = this.$route.query.ruleCode;
- // if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
- // const code = await getCode(this.ruleCode);
- // this.$set(this.form, 'code', code);
- // }
- await this.generateCodeIfNeeded();
- this.getFieldModel();
- // this.getDictList('zeroPartPros');
- },
- async created() {
- //主数据物品是否计算净重
- parameterGetByCode({
- code: 'main_isNetWeight'
- }).then((res) => {
- if (res.value) {
- this.isNetWeight = res.value;
- if (this.clientEnvironmentId != 5) {
- if (this.isNetWeight == 1 && !this.$route.query.id) {
- console.log('dadada');
- this.setDefaultUnpackByConsumable();
- }
- }
- }
- });
- this.isReadOnly =
- this.$route.query.readOnly === 'true' ||
- this.$route.query.readOnly === true;
- console.log(
- '详情页 isReadOnly 状态:',
- this.isReadOnly,
- 'readOnly参数:',
- this.$route.query.readOnly
- );
- parameterGetByCode({
- code: 'mandatory_field'
- }).then((res) => {
- // console.log(res.value, '77777');
- if (res.value) {
- this.mandatoryFieldList = res.value.split(',');
- console.log(this.mandatoryFieldList, '7222222');
- }
- });
- // 行业属性 0:通用行业;1:生物医药行业;2:电线电缆行业;
- parameterGetByCode({
- code: 'industry_attribute'
- }).then((res) => {
- console.log(res.value, '77777');
- if (res.value) {
- console.log(res, '33333333');
- this.industryAttribute = res.value;
- }
- });
- //新增
- this.$set(
- this.form,
- 'categoryLevelId',
- this.$route.query.categoryLevelId
- );
- this.$set(this.form, 'isUpdate', this.$route.query.isUpdate);
- this.isUpdate = this.$route.query.isUpdate;
- this.$set(
- this.form,
- 'categoryLevelName',
- this.$route.query.categoryLevelName
- );
- this.$set(
- this.form,
- 'categoryLevelPath',
- this.$route.query.categoryLevelPath
- );
- this.$set(
- this.form,
- 'categoryLevelPathId',
- this.$route.query.categoryLevelPathId
- );
- this.status = this.$route.query.status;
- this.ruleCode = this.$route.query.ruleCode;
- // if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
- // const code = await getCode(this.ruleCode);
- // this.$set(this.form, 'code', code);
- // }
- await this.generateCodeIfNeeded();
- this.getFieldModel();
- this.getAttributeList('inventory_type');
- this.getDictList('zeroPartPros');
- },
- mounted() {
- if (this.clientEnvironmentId == 4) {
- this.form.measureType = 3;
- }
- },
- methods: {
- getDefaultIsUnpackByConsumable(isConsumable) {
- return Number(isConsumable) === 1 ? 0 : 1;
- },
- setDefaultUnpackByConsumable() {
- this.$set(
- this.categoryWms,
- 'isUnpack',
- this.getDefaultIsUnpackByConsumable(this.form.isConsumable)
- );
- },
- inputSpe(val) {
- if (this.form.measuringUnit == '立方') {
- if (!val || typeof val !== 'string') {
- this.form.volume = 0;
- return;
- }
- let modelArr = val.split('*');
- let modelLong = modelArr[0]; // model规格长度
- let modeWide = modelArr[1]; // model规格宽度
- let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('cm')); // model规格高度
- modeHight = Number(modeHight);
- let aa = (modelLong * modeWide * modeHight) / 1000000;
- console.log(aa, 'aa');
- this.form.volume = aa;
- } else {
- this.form.volume = '';
- }
- this.setNetWeight();
- },
- //计算净重
- setNetWeight() {
- if (
- this.form.specification &&
- this.form.weightUnit == 'KG' &&
- this.isNetWeight == 1
- ) {
- let modelArr = this.form.specification.split('*');
- let modelLong = modelArr[0]; // model规格长度
- let modeWide = modelArr[1]; // model规格宽度
- let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('mm')); // model规格高度
- modeHight = Number(modeHight);
- let volume = (modelLong * modeWide * modeHight) / 1000;
- if (volume) {
- this.$set(
- this.form,
- 'netWeight',
- parseFloat((volume * 7.85) / 1000).toFixed(4)
- );
- } else {
- this.$set(this.form, 'netWeight', 0);
- }
- this.$nextTick(() => {
- // this.$refs.warehouseRefs &&
- // this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
- this.handleInput3();
- });
- // this.form.netWeight = volume*7.85/1000;
- }
- },
- changeMeasureType() {
- this.setNetWeight();
- },
- sanitizePositiveDecimalInput(value) {
- if (value === null || value === undefined) return '';
- const filteredValue = String(value).replace(/[^0-9.]/g, '');
- if (!filteredValue) return '';
- const [integerPart, ...decimalParts] = filteredValue.split('.');
- if (!decimalParts.length) {
- return integerPart;
- }
- return `${integerPart || '0'}.${decimalParts.join('')}`;
- },
- normalizeDecimalFields() {
- ['area', 'roughWeight', 'netWeight', 'volume'].forEach((field) => {
- const value = this.sanitizePositiveDecimalInput(this.form[field]);
- this.$set(
- this.form,
- field,
- value.endsWith('.') ? value.slice(0, -1) : value
- );
- });
- },
- handleAreaInput(value) {
- this.form.area = this.sanitizePositiveDecimalInput(value);
- },
- handleInput(value) {
- this.form.volume = this.sanitizePositiveDecimalInput(value);
- },
- handleInput2(value) {
- this.form.roughWeight = this.sanitizePositiveDecimalInput(value);
- },
- handleInput3(value) {
- this.form.netWeight = this.sanitizePositiveDecimalInput(
- value === undefined ? this.form.netWeight : value
- );
- if (this.form.weightUnit == this.form.measuringUnit) {
- this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
- }
- },
- changeConsumable() {
- this.$set(this.categoryWms, 'inventoryMode', this.form.isConsumable);
- this.setDefaultUnpackByConsumable();
- },
- changeWeightUnit() {
- if (
- this.form.measuringUnit &&
- this.form.packingUnit &&
- this.form.netWeight
- ) {
- this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
- }
- this.setNetWeight();
- },
- async changeUnit() {
- if (this.$route.query.id == '' || this.$route.query.id == null) {
- if (this.form.measuringUnit) {
- // 计量单位是‘立方’ 体积单位默认是‘立方’
- if (
- this.form.measuringUnit == '立方' &&
- this.form.specification != ''
- ) {
- this.form.volumeUnit = '立方';
- this.inputSpe(this.form.specification);
- } else {
- this.form.volume = 0;
- }
- this.categoryPurchase.measuringUnit = this.form.measuringUnit;
- console.log(this.categoryPurchase.measuringUnit, '采购信息');
- // 如果有计量单位和包装单位 默认添加包装组
- if (this.form.packingUnit) {
- await this.$refs.warehouseRefs.defaultBuild(
- this.form.packingUnit
- );
- }
- }
- } else {
- this.isShow = false;
- if (this.form.measuringUnit) {
- this.categoryPurchase.measuringUnit = this.form.measuringUnit;
- if (this.form.packingUnit) {
- console.log(this.form.measuringUnit, 'this.form.measuringUnit');
- console.log(this.form.packingUnit, 'this.form.packingUnit');
- if (this.packageDispositionVOList.length === 0) {
- console.log('如果没有包装组');
- await this.$refs.warehouseRefs.defaultBuild(
- this.form.packingUnit
- );
- }
- }
- }
- this.isShow = true;
- }
- await this.setNetWeight();
- },
- // changeAttribute(val) {
- // if (val.includes(1)) {
- // // this.rules = {
- // // produceType: [
- // // { required: true, message: '请选择生产类型', trigger: 'change' }
- // // ]
- // // };
- // this.rules.produceType = [
- // { required: true, message: '请选择生产类型', trigger: 'change' }
- // ];
- // } else {
- // if (this.rules.produceType) {
- // delete this.rules.produceType;
- // }
- // }
- // },
- changePackagingSpecification(val) {
- this.packagingSpecificationList = val;
- },
- async _getDetails() {
- const data = await getDetails(this.$route.query.id);
- this.isUpdate = this.$route.query.isUpdate;
- this.$set(this.form, 'isUpdate', this.$route.query.isUpdate);
- const info = deepClone(data);
- info.category.produceType = info.category.produceType[0];
- try {
- if (info.category.colorKey) {
- info.category.colorKey = info.category.colorKey.split(',');
- }
- if (info.category.modelKey) {
- info.category.modelKey = info.category.modelKey.split(',');
- }
- if (info.category.imgUrl && info.category.imgUrl.length > 0) {
- info.category.imgUrl = info.category.imgUrl.map((item) => ({
- ...item,
- status: 'done'
- }));
- }
- } catch (error) {}
- this.form = {
- ...info.category
- };
- this.remarkform.remark = info.category.remark;
- this.remarkform.remarkAttach = info.category.remarkAttach;
- // if (this.form.measuringUnit && this.form.packingUnit) {
- // this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
- // }
- this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
- this.judgeSet(info);
- if (this.status == 1) {
- // rootCategoryCode(this.categoryLevelPathId).then((res) => {
- // this.$set(this.form, 'code', res);
- // });
- this.form.createTime = null;
- }
- // 回显上传组件
- this.$nextTick(() => {
- this.$refs.imgUploadRef?.putValue(this.form.imgUrl);
- });
- this.$forceUpdate();
- },
- // 判断字段类型并赋值
- judgeSet(info) {
- console.log('info-------', info);
- if (typeof info.categoryAps == 'string') {
- this.categoryAps = {};
- } else {
- this.categoryAps = info.categoryAps;
- }
- if (typeof info.categoryMes == 'string') {
- this.categoryMes = {};
- } else {
- this.categoryMes = info.categoryMes;
- }
- if (typeof info.categoryMold == 'string') {
- this.categoryMold = {};
- } else {
- this.categoryMold = info.categoryMold;
- }
- if (typeof info.categoryPallet == 'string') {
- this.categoryPallet = {};
- } else {
- this.categoryPallet = info.categoryPallet;
- }
- if (typeof info.categorySales == 'string') {
- this.categorySales = {};
- } else {
- this.categorySales = info.categorySales;
- }
- if (typeof info.categoryPurchase == 'string') {
- this.categoryPurchase = {};
- } else {
- this.categoryPurchase = info.categoryPurchase;
- }
- if (!info.categoryQms || !info.categoryQms?.length) {
- this.categoryQms = [...copyObj(defCategoryQms)];
- } else if (info.categoryQms.length < defCategoryQms.length) {
- //历史数据处理
- // let num= defCategoryQms.length-info.categoryQms.length
- // info.categoryQms.push();
- this.categoryQms = [
- ...info.categoryQms,
- ...copyObj(
- defCategoryQms.slice(
- info.categoryQms.length,
- defCategoryQms.length
- )
- )
- ];
- } else {
- this.categoryQms = info.categoryQms;
- }
- if (typeof info.categoryVehicle == 'string') {
- this.categoryVehicle = {};
- } else {
- this.categoryVehicle = info.categoryVehicle;
- }
- if (typeof info.categoryWms == 'string') {
- this.categoryWms = {};
- } else {
- this.categoryWms = info.categoryWms;
- }
- if (typeof info.packageDispositionVOList == 'string') {
- this.packageDispositionVOList = [];
- } else {
- this.packageDispositionVOList = info.packageDispositionVOList;
- console.log(
- 'this.packageDispositionVOList---!!!----',
- this.packageDispositionVOList
- );
- }
- },
- getFieldModel() {
- fieldModel({ relevance: 't_main_category' }).then((res) => {
- this.fileList = res;
- if (!this.form.extTagField) {
- this.form.extTagField = {
- isConsumables: 0,
- needProductSequence: 0
- }; // 初始化动态模型属性
- }
- // this.$set(this.form.extTagField, 'isConsumables', 0); // 初始化动态模型属性
- if (!this.form.extField) {
- this.$set(this.form, 'extField', {});
- }
- this.fileList.forEach((f) => {
- if (
- Object.prototype.hasOwnProperty.call(this.form.extField, f.prop)
- ) {
- return;
- }
- this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
- // this.$set(this.form.extTagField, f.prop, ''); // 初始化动态模型属性
- });
- });
- },
- levelChange(val) {
- // this.$refs.qualityRefs?.forEach((item) => {
- // item.levelChange(val);
- // // console.log(item)
- // });
- },
- // 确定分类
- async confirmCategory(node, title, PathInfo, ruleCode) {
- this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
- if (title == '选择产品分类') {
- this.$set(this.form, 'productCategoryLevelName', node.name);
- this.$set(this.form, 'productCategoryLevelId', node.id);
- } else {
- this.$set(this.form, 'categoryLevelName', node.name);
- this.$set(this.form, 'categoryLevelId', node.id);
- this.$set(this.form, 'categoryLevelPath', node.name);
- this.$set(this.form, 'categoryLevelPathId', node.id);
- this.PathInfo = PathInfo;
- this.ruleCode = ruleCode;
- // if (ruleCode && ruleCode != '自定义' && this.status != 0) {
- // const code = await getCode(ruleCode);
- // this.$set(this.form, 'code', code);
- // }
- // console.log(this.form, 'this.form');
- await this.generateCodeIfNeeded(true);
- }
- this.$forceUpdate();
- },
- getCodeOpen() {
- if (this.isReadOnly) return;
- let parentId = [];
- if (this.form.categoryLevelPathId?.length) {
- parentId = this.form.categoryLevelPathId?.split(',');
- }
- this.$refs.GetCodeDialogRef.open({
- id: this.form.categoryLevelId,
- parentId: parentId.length > 1 ? parentId[parentId.length - 2] : ''
- });
- },
- setCode(val) {
- this.$set(this.form, 'code', val);
- },
- shouldAutoGenerateCode() {
- const status = Number(this.status);
- return !this.isReadOnly && (status === 1 || status === 2);
- },
- getAutoCodeRouteKey() {
- const { t, id, categoryLevelId, categoryLevelPathId } =
- this.$route.query;
- return [
- t || '',
- id || '',
- this.status || '',
- this.form.categoryLevelId || categoryLevelId || '',
- this.form.categoryLevelPathId || categoryLevelPathId || ''
- ].join('|');
- },
- async generateCodeIfNeeded(force = false) {
- if (!this.shouldAutoGenerateCode()) {
- return;
- }
- const routeKey = this.getAutoCodeRouteKey();
- if (!force && this.autoCodeRouteKey === routeKey) {
- return;
- }
- this.autoCodeRouteKey = routeKey;
- await this.getCode();
- },
- async getCode() {
- let parentId = [];
- let categoryLevelPathId = this.PathInfo?.categoryLevelPathId
- ? this.PathInfo.categoryLevelPathId
- : this.form.categoryLevelPathId;
- if (categoryLevelPathId?.length) {
- parentId = categoryLevelPathId.split(',');
- }
- const options = await listCode({
- id: this.form.categoryLevelId,
- parentId: parentId.length > 1 ? parentId[parentId.length - 2] : ''
- });
- if (options.length > 0) {
- getCode({
- categoryId: options[0].id
- }).then((res) => {
- this.$set(this.form, 'code', res.codeStr);
- });
- } else {
- if (this.ruleCode && this.ruleCode != '自定义') {
- const code = await getCodeApi(this.ruleCode);
- this.$set(this.form, 'code', code);
- }
- }
- },
- async getDictList(code) {
- let { data: res } = await getByCode(code);
- console.log('res----', res);
- // this.lbjtList = res.map((item) => {
- // let values = Object.keys(item);
- // return {
- // value: Number(values[0]),
- // label: item[values[0]]
- // };
- // });
- },
- async getAttributeList(code) {
- let res = await getByCode(code);
- // this.attributeList = res.data.map((item) => {
- // let values = Object.keys(item);
- // return {
- // value: values[0],
- // label: item[values[0]]
- // };
- // });
- let list = res.data.map((item) => {
- let key = Object.keys(item)[0];
- return { value: Number(key), label: item[key] };
- });
- this.attributeList = list;
- console.log(this.attributeList, 'this.attributeList');
- },
- openCategory() {
- if (this.isReadOnly) return;
- this.$refs.categoryRefs.open();
- },
- openCode() {
- this.codeShow = true;
- },
- chooseCode(code) {
- this.$set(this.form, 'code', code);
- this.codeShow = false;
- this.$forceUpdate();
- },
- cancel() {
- // finishPageTab();
- // this.$router.go(-1);
- if (this.$route.query.rootTreeId == 9) {
- this.$router.push({
- path: '/product/oneProduct',
- query: {
- categoryLevelId: this.form.categoryLevelId
- }
- });
- } else {
- this.$router.push({
- path: '/material/product',
- query: {
- categoryLevelId: this.form.categoryLevelId
- }
- });
- }
- },
- verifyDuplicate(obj) {
- return new Promise((resolve, reject) => {
- checkExist(obj).then((res) => {
- if (res) {
- console.log(res, 'res----');
- this.$confirm('系统已有相同的数据', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- resolve(true);
- })
- .catch(() => {
- resolve(false);
- });
- } else {
- resolve(true);
- }
- });
- });
- },
- // 保存
- submit() {
- this.normalizeDecimalFields();
- this.$refs.manageForm.validate(async (valid) => {
- console.log(this.$refs.qualityRefs);
- if (!valid) return;
- let req = {
- name: this.form.name,
- modelType: this.form.modelType,
- specification: this.form.specification,
- isUpdate: this.$route.query.isUpdate
- };
- if (!(await this.verifyDuplicate(req))) return;
- let productionValid = await this.$refs.productionRefs.getFormValid();
- let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
- if (!valid || !productionValid || !warehouseValid) {
- return false;
- }
- let packageDispositionVOList = [];
- if (this.packagingSpecificationList.length > 0) {
- packageDispositionVOList = this.packagingSpecificationList.map(
- (item) => {
- let obj = {
- code: item.code,
- name: item.name
- };
- return [
- {
- ...obj,
- id: item.id0,
- sort: 0,
- status: item.status,
- packageCell: 1,
- packageUnit: item.packageUnit,
- conversionUnit: item.packageUnit
- },
- {
- ...obj,
- id: item.id1,
- sort: 1,
- packageCell: item.minPackageCell,
- packageUnit: item.packageUnit,
- conversionUnit: item.minConversionUnit,
- status: item.status
- },
- {
- ...obj,
- id: item.id2,
- sort: 2,
- packageCell: item.inPackageCell,
- packageUnit: item.minConversionUnit,
- conversionUnit: item.inConversionUnit,
- status: item.status
- },
- {
- ...obj,
- id: item.id3,
- sort: 3,
- packageCell: item.outPackageCell,
- packageUnit: item.inConversionUnit,
- conversionUnit: item.outConversionUnit,
- status: item.status
- }
- ];
- }
- );
- let packagingSpecificationList =
- this.packagingSpecificationList.filter(
- (item) => item.status == 1
- );
- this.form.extField.packingSpecification = packagingSpecificationList
- .map((item) => {
- return [
- `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
- `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
- `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
- ];
- })
- .flat()
- .join(',');
- } else {
- this.form.extField.packingSpecification = '';
- }
- this.loading = true;
- // const imgList = this.remarkform.imgList;
- // const arr = [];
- // if (imgList.length) {
- // imgList.map((item) => {
- // arr.push(item.storePath);
- // });
- // this.form.remarkAttach = arr.join(',');
- // }
- // this.form.remark = this.remarkform.remark
- // ? this.remarkform.remark
- // : '';
- const data = {
- categorySales: this.categorySales,
- categoryPurchase: this.categoryPurchase,
- categoryWms: this.categoryWms,
- categoryAps: this.categoryAps,
- categoryMes: this.categoryMes,
- categoryMold: this.categoryMold,
- categoryPallet: this.categoryPallet,
- categoryQms: this.categoryQms,
- categoryVehicle: this.categoryVehicle,
- category: {
- ...this.form,
- ...this.remarkform,
- ...this.PathInfo
- },
- packageDispositionVOList: packageDispositionVOList.flat()
- };
- if (this.$route.query.status == 1) {
- data.categorySales.id = null;
- data.categoryPurchase.id = null;
- data.category.id = null;
- data.categoryWms.id = null;
- data.categoryAps.id = null;
- data.categoryMes.id = null;
- data.categoryMold.id = null;
- data.categoryPallet.id = null;
- // data.categoryQms.id = null;
- data.categoryVehicle.id = null;
- data.packageDispositionVOList = data.packageDispositionVOList.map(
- (item) => {
- return {
- ...item,
- id: null
- };
- }
- );
- }
- if (data.category.colorKey) {
- data.category.colorKey = data.category.colorKey.toString();
- }
- if (data.category.modelKey) {
- data.category.modelKey = data.category.modelKey.toString();
- }
- data.category.produceType = data.category.produceType
- ? [data.category.produceType]
- : [];
- addMaterial(data)
- .then((msg) => {
- this.loading = false;
- this.$message.success(msg);
- // reloadPageTab({ fullPath: '/material/product' });
- // this.$router.go(-1);
- this.cancel();
- // if (this.$route.query.rootTreeId == 9) {
- // this.$router.push({
- // path: '/product/oneProduct',
- // query: {
- // categoryLevelId: this.form.categoryLevelId
- // }
- // });
- // } else {
- // this.$router.push({
- // path: '/material/product',
- // query: {
- // categoryLevelId: this.form.categoryLevelId
- // }
- // });
- // }
- })
- .catch((e) => {
- this.loading = false;
- });
- });
- },
- //生产类型切换
- produceTypeChange(value) {
- // if (value == 1) {
- // this.attributeList = [
- // {
- // label: '成品',
- // value: 1
- // },
- // {
- // label: '半成品',
- // value: 2
- // },
- // {
- // label: '零件',
- // value: 3
- // },
- // {
- // label: '原材料',
- // value: 4
- // }
- // ];
- // this.form.attributeType = 1;
- // } else {
- // this.attributeList = [
- // {
- // label: '总装(成品)',
- // value: 1
- // },
- // {
- // label: '部件(半成品)',
- // value: 2
- // },
- // {
- // label: '零件',
- // value: 3
- // },
- // {
- // label: '原材料',
- // value: 4
- // }
- // ];
- // this.form.attributeType = 1;
- // }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .ele-page-header {
- border: none;
- }
- .product-detail-tabs {
- ::v-deep .el-tabs__header {
- margin: 0 0 12px;
- border-bottom: 1px solid #d8e6f5;
- }
- ::v-deep .el-tabs__nav {
- border: none;
- }
- ::v-deep .el-tabs__item {
- height: 40px;
- padding: 0 22px;
- border: 1px solid #d8e6f5;
- border-radius: 4px 4px 0 0;
- background: #f5f7fa;
- color: #606266;
- font-weight: 600;
- line-height: 40px;
- transition: all 0.18s ease;
- }
- ::v-deep .el-tabs__item + .el-tabs__item {
- margin-left: 6px;
- }
- ::v-deep .el-tabs__item:hover {
- color: #1684df;
- background: #eef7ff;
- }
- ::v-deep .el-tabs__item.is-active {
- border-color: #1684df;
- background: #1684df;
- color: #fff;
- box-shadow: 0 4px 10px rgba(22, 132, 223, 0.22);
- }
- ::v-deep .el-tabs__content {
- overflow: visible;
- }
- }
- .body-top {
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: #fff;
- .top-left {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-left: -25px;
- .el-form-item {
- margin-bottom: 0;
- }
- }
- }
- .divider {
- margin: 20px 0;
- .title {
- display: flex;
- align-items: center;
- margin-bottom: 10px;
- div {
- width: 8px;
- height: 20px;
- margin-right: 10px;
- }
- span {
- font-size: 20px;
- }
- }
- .ele-width {
- width: 100%;
- height: 2px;
- }
- }
- .form-line {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .line-select {
- margin-left: 15px;
- }
- }
- </style>
|