123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392 |
- <template>
- <div class="salesOrderDetail">
- <el-row>
- <el-col :span="24">
- <el-form
- ref="ruleForm"
- :model="ruleForm"
- status-icon
- :size="'mini'"
- :rules="rulesThis"
- label-width="95px"
- class="demo-ruleForm"
- >
- <el-row>
- <el-col :span="12">
- <el-form-item label="销售方" prop="supplierNo">
- <search-work-company
- :type="'1'"
- :value="ruleForm.supplierNo"
- :size="'mini'"
- :placeholder="'销售方公司'"
- :disabled="false"
- :isDetail="false"
- @searchChange="supplierChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="企业客户" prop="customer_code">
- <search-customer
- :value="ruleForm.customer_code"
- :size="'mini'"
- :names="companyName"
- :placeholder="'企业客户'"
- :disabled="false"
- :is-detail="true"
- @searchChange="customer_code_change"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="所属平台" prop="platform_id">
- <search-terrace
- :value="ruleForm.platform_id"
- :disabled="false"
- :size="'mini'"
- :is_show="'1'"
- :isDetail="false"
- :placeholder="'所属平台'"
- @searchChange="platform_idsearchChange"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="平台订单号" prop="platform_order">
- <el-input
- v-model="ruleForm.platform_order"
- placeholder="如:PO号"
- maxlength="100"
- />
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="回款时间" prop="paytime">
- <el-date-picker
- v-model="ruleForm.paytime"
- type="date"
- style="width: 100%"
- :disabled="false"
- value-format="yyyy-MM-dd"
- :picker-options="pickerOptions"
- placeholder="承诺回款时间"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="其他单号" prop="workNo">
- <el-input
- v-model="ruleForm.workNo"
- placeholder="如:业管单号"
- maxlength="100"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- :label="ruleForm.good_code === '' ? '销售商品' : ''"
- prop="good_code"
- :label-width="ruleForm.good_code === '' ? '95px' : '0'"
- >
- <el-input
- v-if="ruleForm.good_code === ''"
- v-model="ruleForm.good_code"
- placeholder="请选择商品"
- readonly
- maxlength="200"
- @focus="change_good_code"
- />
- <show-data-table
- v-else
- border
- style="margin: 0; padding: 0"
- :sitem="goods_sitem"
- :columns="ShowDataTableColumns"
- >
- <template slot="good_name">
- <img
- v-viewer
- style="width: 23px; height: 23px; margin: 0 5px 0 0"
- class="fl"
- v-if="goods_sitem.good_thumb_img"
- :src="goods_sitem.good_thumb_img"
- alt=""
- />
- <span>{{ goods_sitem.good_name }}</span>
- <span
- v-for="(si, i) in goods_sitem.specinfo"
- :key="si.spec_id + i"
- >
- <span>{{ i === 0 ? "--" : "__" }}</span
- ><span>{{ si.spec_name }}[{{ si.spec_value }}]</span>
- </span>
- </template>
- <template slot="good_info_img">
- <img
- class="fl"
- style="width: 23px; height: 23px; margin: 0 5px 0 0"
- v-viewer
- v-for="(si, i) in goods_sitem.good_info_img"
- :src="si"
- :key="si + i"
- />
- </template>
- <template slot="cat">
- <span v-for="(si, sii) in goods_sitem.cat_info" :key="si.id"
- ><span v-if="sii !== 0">_</span><span>{{ si.name }}</span>
- </span>
- </template>
- <template slot="exclusive">
- <span
- v-for="(si, sii) in goods_sitem.exclusive"
- :key="si.id"
- ><span v-if="sii !== 0">/</span><span>{{ si.name }}</span>
- </span>
- </template>
- <template slot="is_stock">
- <el-tag :size="'mini'">{{
- goods_sitem.is_stock === "1" ? "是" : "否"
- }}</el-tag>
- </template>
- <template slot="weight">
- <span
- >商品总重:{{ goods_sitem.new_weight }}/{{
- goods_sitem.weight_unit
- }}</span
- >
- <span v-if="goods_sitem.metal_id"
- >--{{
- goods_sitem.noble_weight
- ? goods_sitem.noble_weight
- : "0"
- }}g--{{ goods_sitem.metal_name }}---{{
- goods_sitem.gold_price ? goods_sitem.gold_price : "0"
- }}元/g--{{
- goods_sitem.is_gold_price === "0" ? "不" : ""
- }}启用实时金价--{{
- goods_sitem.is_diff === "1" ? "有" : "无"
- }}工差--{{ goods_sitem.config }}---{{
- goods_sitem.other_config
- }}</span
- >
- </template>
- </show-data-table>
- </el-form-item>
- </el-col>
- <el-col :span="12" v-show="ruleForm.good_code">
- <el-row>
- <el-col :span="16">
- <el-form-item label="活动类型" prop="goodtype">
- <el-cascader
- v-model="ruleForm.goodtype"
- :options="goodtype_options"
- placeholder="活动类型"
- style="width: 100%"
- :props="{ expandTrigger: 'hover' }"
- @change="get_new_price"
- ></el-cascader>
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="剩余库存" label-width="75px">
- <el-input
- v-model="ruleForm.activity_stock"
- disabled
- maxlength="200"
- placeholder="剩余库存"
- /> </el-form-item
- ></el-col>
- <!-- <el-col :span="12">
- <el-form-item label="凭证文件" prop="proof_id">
- <el-tooltip
- effect="dark"
- content="查找历史凭证"
- placement="top"
- class="fr"
- >
- <i
- class="el-icon-search tb-icon"
- @click="showVoucherFun"
- ></i>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- v-if="ruleForm.proof_url"
- content="删除"
- placement="top"
- class="fr"
- >
- <i
- class="el-icon-circle-close tb-icon"
- @click="proof_close"
- ></i>
- </el-tooltip>
- <ul class="shangchuan-ul">
- <li v-if="ruleForm.proof_url" class="shiping">
- <div
- v-if="ruleForm.proof_type === '1'"
- class="clearfix"
- >
- <i
- class="el-icon-video-camera hover fl"
- style="
- width: 28px;
- height: 28px;
- font-size: 20px;
- line-height: 28px;
- text-align: center;
- background: rgb(0, 0, 0);
- color: rgb(255, 255, 255);
- "
- />
- <video width="250" controls class="fl">
- <source :src="ruleForm.proof_url" type="video/mp4" />
- <source :src="ruleForm.proof_url" type="video/avi" />
- 您的浏览器不支持Video标签。
- </video>
- </div>
- <div
- v-else-if="ruleForm.proof_type === '2'"
- class="clearfix"
- >
- <img
- style="width: 28px; height: 28px"
- :src="ruleForm.proof_url"
- class="avatar fl"
- />
- </div>
- <div v-else class="clearfix">
- <a :href="ruleForm.proof_url" download="凭证文件"
- >点击下载</a
- >
- </div>
- </li>
- <li v-else class="shiping">暂无凭证</li>
- </ul>
- </el-form-item>
- </el-col> -->
- <el-col :span="12">
- <el-form-item label="销售数量" prop="good_num">
- <digital-input
- :values="ruleForm.good_num"
- :name="'ruleForm.good_num'"
- :placeholder="'销售数量'"
- :min="0"
- :disabled="false"
- :max="100000000000"
- :position="'right'"
- :precision="0"
- :size="'mini'"
- :controls="false"
- :append="''"
- @reschange="number_change($event, 'good_num')"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item label="销售单价" prop="good_price">
- <el-input
- v-model="ruleForm.good_price"
- disabled
- maxlength="20"
- v-loading="priceLoding"
- >
- <template slot="append">元</template></el-input
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-col>
- <el-col :span="6">
- <el-form-item label="到货时间" prop="arrtime">
- <el-date-picker
- v-model="ruleForm.arrtime"
- type="date"
- style="width: 100%"
- :disabled="false"
- value-format="yyyy-MM-dd"
- :picker-options="pickerOptions"
- placeholder="要求到货时间"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="发货方式" prop="sendtype">
- <el-select
- v-model="ruleForm.sendtype"
- placeholder="发货方式"
- style="width: 100%"
- >
- <el-option
- v-for="item in sendtype_options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="ruleForm.good_code ? 12 : 24">
- <el-form-item label="订单备注" prop="remark">
- <el-input
- type="textarea"
- maxlength="250"
- show-word-limit
- :rows="ruleForm.good_code ? 4 : 2"
- placeholder="订单备注"
- v-model="ruleForm.remark"
- >
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="24">
- <search-good-online-modal
- :once="true"
- :sitem="addshowModel"
- :active="true"
- :show-model="showModel"
- @resultList="resultList"
- @cancel="showModel = false"
- />
- </el-col>
- </el-row>
- </el-form>
- </el-col>
- <el-col
- :span="24"
- style="padding: 0 0 22px 0"
- v-if="ruleForm.sendtype && ruleForm.sendtype === '1'"
- >
- <el-form :model="addrForm" ref="addrForm" :size="'mini'">
- <el-table
- :data="addrForm.order_addr"
- border
- :size="'mini'"
- style="width: 100%"
- max-height="200px"
- row-key="key"
- >
- <el-table-column type="index" width="50" show-overflow-tooltip />
- <el-table-column
- prop="receipt_quantity"
- label="收货总数"
- min-width="125"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.edit"
- :prop="
- 'order_addr.' + scope.$index + '.' + 'receipt_quantity'
- "
- :rules="addrRules.receipt_quantity"
- :size="'mini'"
- :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
- >
- <el-input
- v-model="scope.row.receipt_quantity"
- placeholder="收货总数"
- maxlength="20"
- :disabled="!scope.row.edit"
- />
- </el-form-item>
- <span v-if="!scope.row.edit">{{
- scope.row.receipt_quantity
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="contactor"
- label="收件联系人"
- min-width="110"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.edit"
- :prop="'order_addr.' + scope.$index + '.' + 'contactor'"
- :rules="addrRules.contactor"
- :size="'mini'"
- :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
- >
- <el-input
- v-model="scope.row.contactor"
- placeholder="收件联系人"
- maxlength="20"
- :disabled="!scope.row.edit"
- />
- </el-form-item>
- <span v-if="!scope.row.edit">{{ scope.row.contactor }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="mobile"
- label="收货联系电话"
- min-width="130"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.edit"
- :prop="'order_addr.' + scope.$index + '.' + 'mobile'"
- :rules="addrRules.mobile"
- :size="'mini'"
- :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
- >
- <el-input
- v-model="scope.row.mobile"
- placeholder="收货联系电话"
- maxlength="11"
- :disabled="!scope.row.edit"
- />
- </el-form-item>
- <span v-if="!scope.row.edit">{{ scope.row.mobile }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="addr_code"
- label="收货省市区"
- min-width="230"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.edit"
- :prop="'order_addr.' + scope.$index + '.' + 'addr_code'"
- :rules="addrRules.addr_code"
- :size="'mini'"
- :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
- >
- <select-area
- :value="scope.row.addr_code"
- placeholder="收货省市区"
- :disabled="!scope.row.edit"
- :size="'mini'"
- @selectChange="select_area_change($event, scope.$index)"
- />
- </el-form-item>
- <span v-if="!scope.row.edit">{{
- scope.row.addr_code_name
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="addr"
- label="详细地址"
- min-width="170"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-form-item
- v-if="scope.row.edit"
- :prop="'order_addr.' + scope.$index + '.' + 'addr'"
- :rules="addrRules.addr"
- :size="'mini'"
- :style="{ marginBottom: scope.row.edit ? '13px' : '0' }"
- >
- <el-input
- v-model="scope.row.addr"
- placeholder="详细地址"
- maxlength="100"
- :disabled="!scope.row.edit"
- />
- </el-form-item>
- <span v-if="!scope.row.edit">{{ scope.row.addr }}</span>
- </template>
- </el-table-column>
- <el-table-column fixed="right" width="94" show-overflow-tooltip>
- <template slot="header" slot-scope="scope">
- <el-tooltip
- class="fr"
- style="margin: 3px 0 0 8px"
- effect="dark"
- content="手动添加地址"
- placement="top"
- >
- <i
- class="el-icon-circle-plus-outline tb-icon"
- style="color: #63cbe7"
- @click="openHouseModal(-1)"
- ></i>
- </el-tooltip>
- <el-tooltip
- class="fr"
- style="margin: 3px 0 0 8px"
- effect="dark"
- content="导入收货地址"
- placement="top"
- >
- <i
- class="el-icon-upload2 tb-icon"
- style="color: #63cbe7"
- @click="addrmodel = true"
- ></i>
- </el-tooltip>
- <el-tooltip
- class="fr"
- style="margin: 3px 0 0 0"
- effect="dark"
- content="下载收货地址模板"
- placement="top"
- >
- <a class="downloadAddr" href="./static/收货地址模板.xlsx">
- <i
- class="el-icon-download tb-icon"
- style="color: #63cbe7; margin: 0"
- ></i>
- </a>
- </el-tooltip>
- </template>
- <template slot-scope="scope">
- <el-tooltip
- effect="dark"
- content="编辑"
- v-if="!scope.row.edit"
- placement="top"
- >
- <i
- class="el-icon-edit tb-icon"
- @click="openHouseModal(scope.$index)"
- ></i>
- </el-tooltip>
- <el-tooltip
- effect="dark"
- content="保存"
- v-if="scope.row.edit"
- placement="top"
- >
- <i
- class="el-icon-circle-check tb-icon"
- @click="checkRow(scope.$index)"
- ></i>
- </el-tooltip>
- <el-tooltip effect="dark" content="删除" placement="top">
- <i
- class="el-icon-delete tb-icon"
- @click="deleteRow(scope.$index, addrForm.order_addr)"
- ></i>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- </el-col>
- <el-col :span="24">
- <in-addr-model
- :show-model="addrmodel"
- @cancel="addrmodel = false"
- @refresh="addrRefresh"
- />
- <!-- <show-voucher-model
- :showModel="showVoucher"
- :id="goods_sitem.spuCode"
- @cancel="showVoucher = false"
- @searchChange="resvoucher"
- /> -->
- </el-col>
- <el-col
- :span="24"
- style="
- text-align: right;
- padding: 0 0 20px 0;
- display: flex;
- justify-content: space-between;
- "
- >
- <p>
- 订单总金额:{{ accMul(ruleForm.good_num, ruleForm.good_price) || 0 }}
- </p>
- <el-button :size="'mini'" type="primary" @click="submitForm"
- >保 存
- </el-button>
- </el-col>
- </el-row>
- </div>
- </template>
- <script>
- import mixinPage from "@/mixins/elPaginationHandle";
- import resToken from "@/mixins/resToken";
- import asyncRequest from "@/apis/service/sellOut/salesOrder";
- import { isnumber, isMobile } from "@/utils/validate";
- import inAddrModel from "@/components/in-addr-model";
- import showVoucherModel from "@/components/show-voucher-model";
- import searchGoodOnlineModal from "@/components/search-good-online-modal";
- import { addColumns } from "./ShowDataTableColumns";
- import { mapGetters } from "vuex";
- export default {
- name: "salesOrderDetail",
- mixins: [mixinPage, resToken],
- props: ["newTime", "id", "sitem", "type"],
- computed: {
- ...mapGetters(["business_companyNo"]),
- },
- components: {
- inAddrModel,
- showVoucherModel,
- searchGoodOnlineModal,
- },
- watch: {
- newTime: function (val) {
- if (val) {
- this.initForm();
- }
- },
- },
- computed: {
- powers() {
- let tran =
- this.$store.getters.btnList.find(
- (item) => item.menu_route == "salesOrderDetail"
- ) || {};
- if (tran && tran.action && tran.action.length > 0) {
- return tran.action;
- } else {
- return [];
- }
- },
- },
- data() {
- const validatemobile = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("手机号不能为空!"));
- } else {
- if (!isMobile(value)) {
- callback(new Error("手机号格式不正确!"));
- } else {
- callback();
- }
- }
- };
- const validateWeight = (rule, value, callback) => {
- if (value === "") {
- callback(new Error("收货总数不能为空!"));
- } else {
- if (!isnumber(value)) {
- callback(new Error("收货总数仅支持整数!"));
- } else {
- callback();
- }
- }
- };
- return {
- ShowDataTableColumns: addColumns,
- AddrAddEditModalIndex: -1,
- AddrAddEditModalSitem: {},
- showGoodsModel: false,
- showVoucher: false,
- companyName: "",
- showModel: false,
- addrmodel: false,
- addshowModel: {},
- pickerOptions: {
- disabledDate(time) {
- return time.getTime() < Date.now() - 1000 * 60 * 60 * 24;
- },
- },
- goodtype_options: [
- {
- value: "is_activity_0",
- label: "不参与活动",
- children: [
- {
- value: "1",
- label: "常规商品",
- },
- {
- value: "2",
- label: "赠品",
- },
- {
- value: "3",
- label: "样品",
- },
- ],
- },
- {
- value: "is_activity_1",
- label: "参与活动",
- children: [],
- },
- ],
- sendtype_options: [
- {
- value: "1",
- label: "直接发货",
- },
- {
- value: "2",
- label: "延时发货",
- },
- ],
- ruleForm: {
- order_type: "1",
- supplierNo: "", //销售方编码
- customer_code: [], // 企业客户选择
- platform_id: "",
- arrtime: "", //要求到货时间
- // proof_id: "", //凭证ID
- proof_type: "", //凭证类型
- proof_url: "", //凭证地址
- activity_stock: "0",
- is_activity: "0", //是否参与活动,
- goodtype: ["is_activity_0", "1"], //活动类型
- good_num: "", //商品数量
- good_price: "0", //商品单价
- platform_order: "", //平台订单号
- paytime: "", //承诺回款时间
- workNo: "", //其他单号
- sendtype: "1", //发货方式
- remark: "", //备注
- good_code: "", // 商品编号
- },
- rulesThis: this.rules,
- rules: {
- supplierNo: [
- {
- required: true,
- message: "请选择销售方公司",
- trigger: "change",
- },
- ],
- customer_code: [
- {
- type: "array",
- required: true,
- message: "请选择企业客户",
- trigger: "change",
- },
- ],
- platform_id: [
- {
- required: true,
- message: "请选择所属平台",
- trigger: "change",
- },
- ],
- arrtime: [
- {
- required: true,
- message: "要求到货时间",
- trigger: "change",
- },
- ],
- // proof_id: [
- // {
- // required: true,
- // message: "请选择凭证文件",
- // trigger: "change",
- // },
- // ],
- goodtype: [
- {
- type: "array",
- required: true,
- message: "请选择活动类型",
- trigger: "change",
- },
- ],
- good_num: [
- {
- required: true,
- message: "请选择活动类型",
- trigger: "change",
- },
- ],
- sendtype: [
- {
- required: true,
- message: "请选择发货方式",
- trigger: "change",
- },
- ],
- good_code: [
- {
- required: true,
- message: "请选择销售商品",
- trigger: "blur",
- },
- ],
- remark: [
- {
- required: true,
- message: "备注不能为空",
- trigger: "blur",
- },
- ],
- },
- addrForm: {
- order_addr: [], //收货地址
- },
- delAddrList: [],
- delStockList: [],
- addrRules: {
- receipt_quantity: {
- required: true,
- validator: validateWeight,
- trigger: "blur",
- },
- contactor: {
- required: true,
- trigger: "blur",
- message: "联系人不能为空",
- },
- mobile: {
- required: true,
- validator: validatemobile,
- trigger: "blur",
- },
- order_addr: {
- type: "array",
- required: true,
- message: "收货省市区不能为空",
- trigger: "change",
- },
- addr: {
- required: true,
- message: "详细地址不能为空",
- trigger: "blur",
- },
- },
- loading: false,
- queryId: "",
- status: "",
- goods_sitem: {},
- order_good_num: {
- ogood_type: "",
- ogood_num: "0",
- },
- priceLoding: false,
- };
- },
- mounted() {
- this.initForm();
- },
- methods: {
- //乘法精度问题
- 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) {}
- return (
- (Number(s1.replace(".", "")) * Number(s2.replace(".", ""))) /
- Math.pow(10, m)
- );
- },
- async initForm() {
- this.status = "";
- this.queryId = this.$route.query.id;
- this.rulesThis = this.rules;
- this.resetForm();
- },
- getNewTime() {
- this.newTime = new Date().valueOf();
- },
- async resetForm() {
- // 重置
- await this.$nextTick(() => {
- if (this.$refs.ruleForm) {
- this.$refs.ruleForm.resetFields();
- this.$refs.ruleForm.clearValidate();
- this.ruleForm = {
- order_type: "1",
- supplierNo: this.business_companyNo || "", //销售方编码
- customer_code: [], // 企业客户选择
- platform_id: "",
- arrtime: "", //要求到货时间
- // proof_id: "", //凭证ID
- proof_type: "", //凭证类型
- proof_url: "", //凭证地址
- activity_stock: "0",
- goodtype: ["is_activity_0", "1"], //活动类型
- good_num: "0", //商品数量
- good_price: "0", //商品单价
- platform_order: "", //平台订单号
- paytime: "", //承诺回款时间
- workNo: "", //其他单号
- sendtype: "1", //发货方式
- remark: "", //备注
- good_code: "", // 商品编号
- };
- }
- if (this.$refs.addrForm) {
- this.$refs.addrForm.resetFields();
- this.$refs.addrForm.clearValidate();
- const { addrs } = this.sitem;
- this.addrForm = {
- order_addr: [],
- };
- this.delAddrList = [];
- if (addrs && addrs.length > 0) {
- addrs.forEach((v) => {
- const { area_code, city_code, provice_code } = v.addr_code;
- let model = {
- edit: false,
- receipt_quantity: v.receipt_quantity || "",
- contactor: v.contactor || "",
- mobile: v.mobile || "",
- addr_code:
- area_code && city_code && provice_code
- ? [provice_code, city_code, area_code]
- : [],
- addr: v.addr || "",
- id: v.id,
- is_del: 0,
- };
- this.delAddrList.push(model);
- this.addrForm.order_addr.push(model);
- });
- }
- }
- });
- },
- // resvoucher(e) {
- // const { id, proof_type, proof_url } = e;
- // this.ruleForm.proof_id = id || "";
- // this.ruleForm.proof_type = proof_type || "";
- // this.ruleForm.proof_url = proof_url || "";
- // this.$refs.ruleForm.validateField("proof_id");
- // this.showVoucher = false;
- // },
- // proof_close() {
- // this.ruleForm.proof_id = "";
- // this.ruleForm.proof_type = "";
- // this.ruleForm.proof_url = "";
- // this.$refs.ruleForm.validateField("proof_id");
- // },
- addrRefresh(e) {
- const { list } = e;
- this.addrForm.order_addr.push(...list);
- },
- async resultList(e) {
- this.showModel = false;
- if (e.length === 1) {
- let ssitem = JSON.parse(JSON.stringify(e[0]));
- await this.get_goods_detail(ssitem.skuCode);
- this.ruleForm.good_code = this.goods_sitem.skuCode;
- } else {
- this.goods_sitem = {};
- this.ruleForm.good_code = "";
- }
- this.$refs.ruleForm.validateField("good_code");
- // this.ruleForm.proof_id = "";
- // this.ruleForm.proof_url = "";
- // this.ruleForm.proof_type = "";
- // this.$refs.ruleForm.validateField("proof_id");
- if (e.length === 1) {
- await this.get_goods_active();
- }
- },
- async get_goods_active() {
- const { good_code, supplierNo, platform_id } = this.ruleForm;
- let model = {
- skuCode: good_code,
- companyNo: supplierNo,
- platform_id,
- };
- const { code, data, message } = await asyncRequest.goods_active(model);
- if (code === 0) {
- const { act, good } = data;
- let actlist = act.length > 0 ? JSON.parse(JSON.stringify(act)) : [];
- actlist.forEach((a) => {
- a.value = a.activity_code;
- a.label = a.activity_name;
- });
- this.goodtype_options[1].children = [];
- this.goodtype_options[1].children.push(...actlist);
- let goodItem =
- good.length > 0 ? JSON.parse(JSON.stringify(good[0])) : {};
- if (goodItem.good_name) {
- this.goodtype_options[0].children.map((b) => {
- b.activity_stock = goodItem ? goodItem.stock_num + "" : "0";
- return b;
- });
- console.log(this.goodtype_options);
- }
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- }
- },
- async get_goods_detail(skuCode) {
- let { code, data, message } = await asyncRequest.goods_detail({
- skuCode: skuCode,
- });
- if (code === 0) {
- this.goods_sitem = data;
- console.log("1111111111111111", this.goods_sitem);
- this.goods_sitem.good_info_img =
- this.goods_sitem.good_info_img.split(",");
- const { weight } = this.goods_sitem;
- let kgnum = parseInt((weight * 1) / 1000);
- let gnum = (weight * 1) % 1000;
- let new_weight,
- weight_unit = "";
- if (kgnum > 0) {
- weight_unit = "Kg";
- new_weight = `${kgnum}.${gnum}`;
- } else {
- new_weight = weight;
- weight_unit = "g";
- }
- this.goods_sitem.new_weight = new_weight;
- this.goods_sitem.weight_unit = weight_unit;
- this.ruleForm.good_code = this.goods_sitem.good_code;
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- }
- },
- showVoucherFun() {
- if (this.goods_sitem && this.goods_sitem.spuCode) {
- this.showVoucher = true;
- } else {
- this.$message.warning("请选择商品!");
- return;
- }
- },
- async addGoodsRes(e) {
- if (e && e.length === 1) {
- this.ruleForm.good_name = e[0].good_name;
- this.ruleForm.good_code = e[0].type_code;
- } else {
- this.ruleForm.good_name = "";
- this.ruleForm.good_code = "";
- }
- this.$refs.ruleForm.validateField("good_code");
- if (this.ruleForm.good_code !== "" && this.queryId === "add") {
- } else {
- }
- },
- async number_change(e, key) {
- this.ruleForm[key] = e + "" || "0";
- this.$refs.ruleForm.validateField(key);
- if (key === "good_num") {
- await this.get_new_price();
- }
- },
- async get_new_price() {
- const { goodtype, good_num } = this.ruleForm;
- let oldGood_type = goodtype.length === 2 ? goodtype[1] : "";
- if (oldGood_type == 2 || oldGood_type == 3) {
- this.ruleForm.good_price = 0;
- }
- const { ogood_type, ogood_num } = this.order_good_num;
- console.log(
- `oldGood_type${oldGood_type}-ogood_type${ogood_type}-good_num${good_num}-ogood_num${ogood_num}`
- );
- if (oldGood_type === ogood_type && good_num === ogood_num) {
- this.order_good_num = {
- ogood_type: goodtype.length === 2 ? goodtype[1] : "",
- ogood_num: this.ruleForm.good_num,
- };
- return;
- }
- //activity_stock
- if (goodtype.length === 2) {
- this.goodtype_options.forEach((a) => {
- if (a.children && a.children.length) {
- a.children.forEach((b) => {
- if (b.value === goodtype[1]) {
- console.log(b.activity_stock);
- this.ruleForm.activity_stock = b.activity_stock || "0";
- }
- });
- }
- });
- } else {
- this.ruleForm.activity_stock = 0 + "";
- }
- if (!this.priceLoding) {
- const { isok, price, stock } = await this.set_salegetprice();
- this.ruleForm.good_price = isok ? price : "0";
- }
- this.order_good_num = {
- ogood_type: goodtype.length === 2 ? goodtype[1] : "",
- ogood_num: this.ruleForm.good_num,
- };
- },
- change_good_code() {
- const { supplierNo, platform_id } = this.ruleForm;
- if (supplierNo === "") {
- this.$message.warning("请选择销售方公司!");
- return;
- }
- if (platform_id === "") {
- this.$message.warning("请选择所属平台!");
- return;
- }
- this.addshowModel = {
- company_id: supplierNo,
- platform_code: platform_id,
- };
- this.showModel = true;
- },
- customer_code_change(e) {
- if (e && e.code) {
- this.ruleForm.customer_code = [e.code];
- } else {
- this.ruleForm.customer_code = [];
- }
- this.$refs.ruleForm.validateField("customer_code");
- },
- supplierChange(e) {
- const { id, code, label } = e;
- this.ruleForm.supplierNo = code || "";
- this.$refs.ruleForm.validateField("supplierNo");
- // this.ruleForm.proof_id = "";
- // this.ruleForm.proof_url = "";
- // this.ruleForm.proof_type = "";
- // this.$refs.ruleForm.validateField("proof_id");
- this.ruleForm.good_code = "";
- this.goods_sitem = {};
- // this.$refs.ruleForm.validateField("proof_id");
- },
- platform_idsearchChange(e) {
- const { id, code, label } = e;
- this.ruleForm.platform_id = id || "";
- this.$refs.ruleForm.validateField("platform_id");
- // this.ruleForm.proof_id = "";
- // this.ruleForm.proof_url = "";
- // this.ruleForm.proof_type = "";
- // this.$refs.ruleForm.validateField("proof_id");
- this.ruleForm.good_code = "";
- this.goods_sitem = {};
- // this.$refs.ruleForm.validateField("proof_id");
- },
- openHouseModal(index) {
- let findex = this.addrForm.order_addr.findIndex((v) => v.edit === true);
- if (findex !== -1) {
- this.$message.warning("当前已有地址在编辑,请保存后再试!");
- return;
- } else {
- if (index === -1) {
- this.addrForm.order_addr.push({
- edit: true,
- receipt_quantity: "",
- contactor: "",
- mobile: "",
- addr_code: [],
- addr: "",
- });
- } else {
- this.addrForm.order_addr[index].edit = true;
- }
- }
- },
- //省市区选择
- select_area_change(e, index) {
- this.addrForm.order_addr[index].addr_code = e;
- },
- //省市区保存某一行
- async checkRow(rowIndex) {
- await this.$refs.addrForm.validate(async (valid) => {
- if (valid) {
- const { addr_code } = this.addrForm.order_addr[rowIndex];
- if (addr_code && addr_code.length === 3) {
- let arrCode = addr_code[addr_code.length - 1];
- // console.log(model);
- let { code, data, message } = await asyncRequest.addrall({
- code: arrCode,
- });
- if (code === 0) {
- const { province, city, area } = data;
- let province_name =
- province && province.name ? province.name : "";
- let city_name = city && city.name ? city.name : "";
- let area_name = area && area.name ? area.name : "";
- this.addrForm.order_addr[rowIndex].addr_code_name =
- province_name && city_name && area_name
- ? `${province_name}/${city_name}/${area_name}`
- : "";
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- }
- } else {
- this.addrForm.order_addr[rowIndex].addr_code_name = "";
- }
- this.addrForm.order_addr[rowIndex].edit = false;
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- // 删除收货地址操作
- deleteRow(index, rows) {
- rows.splice(index, 1);
- },
- async submitForm() {
- await this.$refs.ruleForm.validate(async (valid) => {
- if (valid) {
- this.loading = true;
- const { sendtype, good_num, goodtype } = JSON.parse(
- JSON.stringify(this.ruleForm)
- );
- const { order_addr } = JSON.parse(JSON.stringify(this.addrForm));
- let key_0 = goodtype[0];
- let key_1 = goodtype[1];
- if (order_addr.length === 0 && sendtype === "1") {
- this.$message.warning("至少填写一条地址信息!");
- this.loading = false;
- return;
- }
- let model = JSON.parse(JSON.stringify(this.ruleForm));
- model.addrlist = [];
- model.customer_code = model.customer_code.toString();
- delete model["proof_type"];
- delete model["proof_url"];
- delete model["good_price"];
- if (sendtype === "1") {
- let addrT = 0,
- isAEdit = false;
- order_addr.forEach((v2) => {
- if (v2.edit) {
- isAEdit = true;
- }
- addrT += parseInt(v2.receipt_quantity);
- let model2 = {
- contactor: v2.contactor,
- mobile: v2.mobile,
- addr: v2.addr,
- receipt_quantity: v2.receipt_quantity,
- addr_code: v2.addr_code,
- };
- model.addrlist.push(model2);
- });
- if (isAEdit) {
- this.$message.warning("请保存地址信息!");
- this.loading = false;
- return;
- }
- if (good_num * 1 !== addrT) {
- this.$message.warning("地址收货总数与销售总数量不一致!");
- this.loading = false;
- return;
- }
- }
- let priceres = await this.set_salegetprice();
- if (!priceres.isok) {
- this.loading = false;
- return;
- }
- model.is_activity = key_0 === "is_activity_0" ? "0" : "1";
- model.goodtype = key_0 === "is_activity_1" ? "1" : key_1;
- model.act_code = key_0 === "is_activity_1" ? Fkey_1 : "";
- let res = await asyncRequest.add(model);
- this.loading = false;
- if (res && res.code === 0) {
- this.$notify.success({
- title: "订单创建成功!",
- message: "",
- });
- 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 set_salegetprice() {
- this.priceLoding = true;
- let resModel = {
- isok: true,
- price: "0",
- };
- const { good_num, good_code, goodtype } = this.ruleForm;
- let key_1 = goodtype[1];
- let key_0 = goodtype[0];
- let model = {
- skuCode: good_code,
- sale_num: good_num,
- is_activity: key_0 === "is_activity_0" ? "0" : "1",
- act_code: key_0 === "is_activity_1" ? key_1 : "",
- };
- console.log(model);
- let { code, message, data } = await asyncRequest.salegetprice(model);
- console.log(code, message, data);
- if (code === 0) {
- const { sale_price } = data;
- resModel.price = sale_price + "";
- let oldGood_type = goodtype.length === 2 ? goodtype[1] : "";
- if (
- key_0 === "is_activity_0" &&
- (oldGood_type == 2 || oldGood_type == 3)
- ) {
- resModel.price = 0 + "";
- }
- } else if (code >= 100 && code <= 104) {
- await this.logout();
- } else {
- this.$message.warning(message);
- resModel.isok = false;
- }
- this.priceLoding = false;
- return resModel;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .salesOrderDetail {
- }
- </style>
-
-
|