123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392 |
- <template>
- <div class="detail-container">
- <el-page-header
- @back="goBack"
- :content="listItem ? '编辑' : '新增'"
- ></el-page-header>
- <div class="main-title">
- <div class="title">订单信息</div>
- </div>
- <el-form
- ref="mainForm"
- :model="mainForm"
- label-width="120px"
- size="small"
- label-position="right"
- >
- <el-row :gutter="20">
- <el-col
- :xs="24"
- :sm="12"
- :lg="8"
- v-if="!listItem"
- @click.native="handleShow"
- >
- <el-form-item label="销售政策编号" prop="policyCode">
- <el-input
- v-model="policyId"
- placeholder="销售政策编号"
- readonly
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" v-else>
- <el-form-item label="销售政策编号" prop="policyCode">
- <el-input
- v-model="mainForm.policyCode"
- placeholder="销售政策编号"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
- <el-form-item label="单据日期" prop="date">
- <el-date-picker
- v-model="mainForm.date"
- type="datetime"
- disabled
- style="width: 100%"
- placeholder="选择日期"
- >
- </el-date-picker>
- </el-form-item>
- </el-col>
- <!-- <el-col :xs="24" :sm="12" :lg="8">
- <el-form-item label="产品大类" prop="type">
- <el-select
- v-model="mainForm.type"
- placeholder="选择产品大类"
- style="width: 100%"
- >
- <el-option
- v-for="item in typeList"
- :key="item.dictCode"
- :label="item.dictValue"
- :value="item.dictCode"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col> -->
- <el-col :xs="24" :sm="8" :lg="8">
- <el-form-item label="备注" prop="remark">
- <el-input
- v-model="mainForm.remark"
- placeholder="请输入备注"
- ></el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <div class="main-title">
- <div class="title">货品信息</div>
- <div v-if="!listItem">
- <el-select
- v-model="warehouseValue"
- placeholder="请选择发货仓库"
- size="small"
- style="margin-right: 10px"
- >
- <el-option
- :label="item.name"
- :value="item.id"
- v-for="(item, index) in warehouseList"
- :key="index"
- ></el-option>
- </el-select>
- <el-button
- type="primary"
- size="small"
- icon="el-icon-search"
- @click="checkStock"
- >检查库存</el-button
- >
- <el-divider direction="vertical"></el-divider>
- </div>
- </div>
- <div class="table" style="margin-top: 20px">
- <el-table
- :data="goodsList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- max-height="400"
- >
- <el-table-column
- align="center"
- label="序号"
- type="index"
- width="50"
- ></el-table-column>
- <el-table-column
- align="center"
- label="销售类型"
- prop="saleTypeName"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="存货编码"
- prop="materialNumber"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="产品名称"
- prop="materialName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="规格型号"
- prop="specification"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="单位"
- prop="unit"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="单价"
- prop="price"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="总数量"
- prop="qty"
- min-width="100"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-input v-model="scope.row.qty" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="订单金额"
- min-width="100"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.price * scope.row.qty }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="返利钱包"
- prop="customerWalletId2"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.customerWalletId2"
- placeholder="选择返利钱包"
- size="small"
- @change="changeWallet(scope.$index)"
- >
- <el-option
- v-for="item in scope.row.rebateWallets"
- :key="item.customerWalletId"
- :label="item.name"
- :value="item.customerWalletId"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="返利金额"
- min-width="100"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{
- (scope.row.price * scope.row.qty * (scope.row.rebateRate * 100)) /
- 100 || 0
- }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="格力折扣"
- min-width="100"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.qty * scope.row.discAmount }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="已退数量"
- prop="retiredQty"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="现金钱包"
- prop="customerWalletId"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-select
- v-model="scope.row.customerWalletId"
- placeholder="选择现金钱包"
- size="small"
- >
- <el-option
- v-for="item in scope.row.wallets"
- :key="item.customerWalletId"
- :label="item.name"
- :value="item.customerWalletId"
- >
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="实付金额"
- prop="qty"
- min-width="100"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{
- (scope.row.price * scope.row.qty * 100 -
- ((scope.row.price *
- scope.row.qty *
- (scope.row.rebateRate * 100)) /
- 100) *
- 100 -
- ((scope.row.qty * (scope.row.discAmount * 100)) / 100) * 100) /
- 100 || 0
- }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="是否直调"
- prop="isDirectTransfer"
- min-width="100"
- >
- <template slot-scope="scope">
- <el-checkbox v-model="scope.row.isDirectTransfer"></el-checkbox>
- </template>
- </el-table-column>
- <!-- <el-table-column
- align="center"
- label="直调数量"
- prop="directTransferQty"
- min-width="100"
- >
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.directTransferQty"
- size="small"
- ></el-input>
- </template>
- </el-table-column> -->
- <el-table-column
- align="center"
- label="备注"
- prop="remark"
- min-width="160"
- >
- <template slot-scope="scope">
- <el-input v-model="scope.row.remark" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="税率"
- prop="tax"
- min-width="100"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="总仓库"
- prop="status1"
- min-width="100"
- show-overflow-tooltip
- v-if="!listItem"
- >
- <template slot-scope="scope">
- <div>{{ scope.row.status1 | status1Filter }}</div>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="仓库状态"
- prop="status2"
- min-width="100"
- show-overflow-tooltip
- v-if="!listItem"
- >
- <template slot-scope="scope">
- <div>{{ status2Filter(scope.row) }}</div>
- </template>
- </el-table-column>
- <el-table-column align="center" label="操作" width="100" fixed="right">
- <template slot-scope="scope">
- <!-- <el-button
- type="text"
- @click="(dialogVisible = true), (cid = scope.row.id)"
- >修改</el-button
- > -->
- <el-button type="text" @click="deleteItem(scope.$index)"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-dialog :visible.sync="dialogVisible" width="50%">
- <el-form label-width="80px" :inline="false" size="small">
- <el-form-item label="单据日期" prop="date">
- <el-date-picker
- v-model="mainForm.date"
- type="datetime"
- value-format="yyyy-MM-dd HH:mm:ss"
- style="width: 100%"
- placeholder="选择日期"
- >
- </el-date-picker>
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button type="primary" size="small" @click="hendleEdit"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- <div class="page-footer">
- <div class="footer" :class="classObj">
- <el-button type="primary" @click="clickSubmitForm">保 存</el-button>
- <el-popconfirm
- title="确定关闭吗?"
- @onConfirm="goBack"
- style="margin-left: 10px"
- >
- <el-button slot="reference">关 闭</el-button>
- </el-popconfirm>
- </div>
- </div>
- <el-dialog
- :visible.sync="isShowDialog"
- @close="handleClose"
- width="80%"
- :close-on-click-modal="false"
- title="引用销售政策"
- >
- <template>
- <el-form
- :model="screenForm"
- ref="screenForm"
- label-width="120px"
- size="small"
- >
- <el-row :gutter="20">
- <el-col :xs="24" :sm="6" :lg="6">
- <el-form-item label="销售政策">
- <el-select
- v-model="screenForm.policyId"
- placeholder="选择销售政策"
- @change="handlePolicy"
- filterable
- :disabled="disabled"
- style="width: 100%"
- >
- <el-option
- v-for="(item, index) in policyList"
- :key="index"
- :label="item.title"
- :value="item.code"
- ></el-option>
- </el-select> </el-form-item
- ></el-col>
- <el-col :xs="24" :sm="6" :lg="6">
- <el-form-item label="条件">
- <el-select
- v-model="screenForm.factorId"
- filterable
- @change="handleFactor"
- placeholder="选择条件"
- style="width: 100%"
- >
- <el-option
- v-for="(item, index) in factor"
- :key="item.id"
- :label="'条件' + (index + 1)"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="6" :lg="6">
- <el-form-item label="销售类型">
- <el-select
- v-model="screenForm.saleTypeCode"
- filterable
- placeholder="选择销售类型"
- style="width: 100%"
- >
- <el-option
- v-for="item in ztypeList"
- :key="item.id"
- :label="item.saleName"
- :value="item.saleCode"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="6" :lg="6" class="tr">
- <el-button
- type="primary"
- size="small"
- @click="handlePolicyTypeList"
- >查询</el-button
- >
- </el-col>
- </el-row>
- </el-form>
- <template v-if="!dataList.length">
- <el-row :gutter="20" style="margin: 10px 0">
- {{ cusIndex > 0 ? "选择配提机型" : "选择限定机型" }}
- {{ "(" + pop + ")" }}
- </el-row>
- <el-table
- v-loading="listLoading"
- :data="popDataArr[cusIndex]"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- @select-all="handleSelectionChange"
- @selection-change="handleSelectionChange"
- stripe
- >
- <el-table-column
- align="center"
- type="selection"
- :selectable="selectable"
- width="55"
- >
- </el-table-column>
- <template v-for="col in columns">
- <el-table-column
- v-if="col.num"
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-input v-model="scope.row.qty" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column
- v-else-if="col.jie"
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.qty * scope.row.price || 0 }}
- </template>
- </el-table-column>
- <el-table-column
- v-else
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- </el-table-column>
- </template>
- </el-table>
- <div style="margin: 10px 0">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[10]"
- :page-size="10"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" v-if="cusIndex > 0" @click="handleShang"
- >上一步</el-button
- >
- <el-button
- type="primary"
- @click="handleCondition"
- v-if="popArr.length != cusIndex + 1"
- >下一步</el-button
- >
- <el-button
- type="primary"
- @click="hanlePopData"
- v-if="popArr.length == cusIndex + 1"
- >完成</el-button
- >
- </span>
- </template>
- <template v-else>
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- @select-all="handleSelectionChange"
- @selection-change="handleSelectionChange"
- stripe
- >
- <el-table-column
- align="center"
- type="selection"
- :selectable="selectable"
- width="55"
- >
- </el-table-column>
- <template v-for="col in columns">
- <el-table-column
- v-if="col.num"
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- <el-input v-model="scope.row.qty" size="small"></el-input>
- </template>
- </el-table-column>
- <el-table-column
- v-else-if="col.jie"
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.qty * scope.row.price || 0 }}
- </template>
- </el-table-column>
- <el-table-column
- v-else
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- </el-table-column>
- </template>
- </el-table>
- <div style="margin: 10px 0">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[10]"
- :page-size="10"
- layout="total, sizes, prev, pager, next, jumper"
- :total="total"
- >
- </el-pagination>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button
- type="primary"
- @click="hanlePopData"
- >完成</el-button
- >
- </span>
- </template>
- </template>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- getDetail,
- addData,
- editData,
- getSalesTypeList,
- getGoodsList,
- getWalletList,
- getWarehouseList,
- policyList,
- checkStock,
- typeList,
- getpolicyList,
- getConditionList,
- getConditionDetail,
- getpolicyTypeList,
- getMaterialTypeList ,
- getPolicyConditionList,
- } from "@/api/supply/policy";
- import { getDictList } from "@/api/common";
- import { findElem } from "@/utils/util";
- export default {
- name: "RetailForm",
- componentName: "RetailForm",
- props: ["listItem"],
- filters: {
- status1Filter(val) {
- if (val === "" || val === null || val === undefined) return "未检查";
- else if (val === 0) return "无货";
- else if (val > 0 && val <= 30) return val;
- else if (val > 30 && val <= 1000) return "有货";
- else if (val > 1000) return "充足";
- },
- },
- data() {
- return {
- tableData: [],
- currentPage: 1, // 当前页码
- pageSize: 10, // 每页数量
- listTotal: 0, // 列表总数
- cusIndex: 0,
- total: 0,
- radio: "",
- pop: "",
- dialogVisible: false,
- factor: [],
- popArr: [],
- mainForm: {
- id: "",
- date: "",
- type: "",
- ztype: "",
- remark: "",
- policyCode: "",
- policyRemark: "",
- policyId: "",
- },
- // mainFormRules: {
- // type: [{ required: true, message: "请选择品类", trigger: "change" }],
- // },
- goodsList: [],
- warehouseList: [],
- warehouseValue: "",
- isShowDialog: false,
- screenForm: {
- policyId: "",
- saleTypeCode: "",
- factorId: "",
- },
- currentPage: 1,
- listTotal: 0,
- salesTypeList: [],
- typeList: [],
- ztypeList: [],
- leftGoodsList: [],
- rightGoodsList: [],
- leftSelection: [],
- rightSelection: [],
- policyList: [],
- xjWalletList: [],
- flWalletList: [],
- dataList: [],
- columns: [
- {
- prop: "saleTypeName",
- lable: "销售类型",
- widht: 160,
- },
- {
- prop: "materialName",
- lable: "货品名称",
- widht: 160,
- },
- {
- prop: "specification",
- lable: "规格型号",
- widht: 160,
- },
- {
- prop: "qty",
- lable: "数量",
- widht: 160,
- num: true,
- },
- {
- prop: "price",
- lable: "单价",
- widht: 160,
- },
- {
- prop: "zong",
- lable: "金额",
- jie: true,
- },
- ],
- listLoading: false,
- popDataArr: [],
- radioObj: {},
- step: 0,
- policyId: "",
- policyConditionId: "",
- multipleSelection: [],
- multipleData: [],
- disabled: false,
- cid: "",
- };
- },
- computed: {
- sidebar() {
- return this.$store.state.app.sidebar;
- },
- classObj() {
- return {
- hideSidebar: !this.sidebar.opened,
- openSidebar: this.sidebar.opened,
- };
- },
- comxjWalletList() {
- return (c) => {
- console.log(c, "现金钱包");
- const walle = [];
- const ovalVall = c == undefined || !c.length ? [] : c;
- for (let i = 0; i < this.xjWalletList.length; i++) {
- for (let j = 0; j < ovalVall.length; j++) {
- if (this.xjWalletList[i].walletRebateId == ovalVall[j].walletId) {
- walle.push(this.xjWalletList[i]);
- }
- }
- }
- return walle;
- };
- },
- comText() {
- return (val) => {
- if (this.cusIndex - 1 == 0) {
- const params = this.radio.split("&");
- return this.dataList.filter((k) => {
- return k.id == params[0];
- })[0][val];
- } else {
- const params =
- this.radioObj["radio" + (this.cusIndex - 1)].split("&");
- return this.popDataArr[this.cusIndex - 2].filter((k) => {
- return k.id == params[0];
- })[0][val];
- }
- };
- },
- // pickerOptions({ $props }) {
- // return {
- // disabledDate: (time) => {
- // return time.getTime() < Date.now() - 1 * 24 * 60 * 60 * 1000;
- // },
- // };
- // },
- },
- created() {
- this.getDictList();
- this.getWalletList();
- this.getWarehouseList();
- this.getTypeList();
- if (this.listItem) {
- this.getDetail();
- }
- },
- beforeUpdate() {},
- methods: {
- // 返回列表
- goBack() {
- this.$emit("backListFormDetail");
- },
- // 选择销售政策获取政策条件列表
- handlePolicy(e) {
- this.factor = [];
- this.popDataArr = [];
- this.total = 0;
- this.screenForm.factorId = "";
- // 选择销售政策PolidcyId改变获取条件列表
- getPolicyConditionList({ policyId: e }).then((res) => {
- this.factor = res.data;
- });
- },
- hendleEdit(val, index) {
- this.dialogVisible = false
- // let params = {
- // id: this.cid,
- // theTime: this.mainForm.date,
- // mainId: this.mainForm.type,
- // mainName: this.mainForm.mainName,
- // remark: this.mainForm.remark,
- // type: 2,
- // retailOrderItemList: this.goodsList,
- // policyId: this.policyId,
- // };
- // editData(params).then((res) => {
- // this.$successMsg("编辑成功");
- // this.getDetail();
- // });
- },
- //获取条件相对应的比列
- handleFactor(e) {
- const data = this.factor.filter((k) => {
- return k.id == e;
- })[0];
- console.log(data, "kkkk");
- this.pop = data.pop;
- this.popArr = data.pop.split(":");
- this.screenForm.policyId = data.policyId;
- this.policyConditionId = data.id;
- },
- //引用销售政策搜索
- handlePolicyTypeList() {
- if (this.screenForm.factorId) {
- this.getConditionList(this.policyConditionId, this.cusIndex + 1);
- } else {
- this.getMaterialTypeList();
- }
- },
- // 获取某一个比例下的数据 ,查询popType 当前 this.cusIndex+1
- getConditionList(policyConditionId, popType) {
- getConditionList({
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- policyConditionId,
- popType,
- }).then((res) => {
- const datas = res.data.records;
- this.total = res.data.total;
- console.log(this.goodsList.length, 223424);
- if (this.goodsList.length) {
- for (let p = 0; p < this.goodsList.length; p++) {
- for (let q = 0; q < datas.length; q++) {
- if (this.goodsList[p].id == datas[q].id) {
- datas[q].disabled = true;
- }
- }
- }
- }
- for (let i = 0; i < res.data.records.length; i++) {
- res.data.records[i].qty = 1;
- }
- if (this.popDataArr.length) {
- this.popDataArr.splice(this.cusIndex, 1);
- }
- if (this.cusIndex == 0) {
- this.popDataArr = [];
- }
- this.popDataArr = [...this.popDataArr, datas];
- });
- },
- // 下一步获取某个政策条件比例数据
- handleCondition() {
- if (this.multipleSelection.length) {
- this.cusIndex += 1;
- this.disabled = true;
- this.multipleData.push(this.multipleSelection);
- console.log(this.multipleData, "push", this.cusIndex);
- this.getConditionList(this.policyConditionId, this.cusIndex + 1);
- } else {
- this.$errorMsg("请选择");
- }
- },
- /**
- * 根据条件禁用行复选框
- * 函数返回值为false则禁用选择(反之亦然)
- * @param {Object} row - 行数据
- * @param {String} index - 索引值
- * @return Boolean
- */
- selectable: function (row, index) {
- // row.disabled == undefined 才能被选中
- if (row.disabled == undefined) {
- return true;
- }
- // 函数必须有返回值且是布尔值
- // 页面刷新后该函数会执行 N 次进行判断(N 为表格行数)
- // 如果没有返回值则默认返回false(全部无法选中)
- },
- // 上一步
- handleShang() {
- this.cusIndex -= 1;
- this.cusIndex == 0 ? (this.disabled = false) : "";
- this.multipleData.splice(this.cusIndex, 1);
- },
- // 条件数据多选
- handleSelectionChange(val) {
- this.multipleSelection = val;
- console.log(this.multipleSelection);
- },
- hanlePopData() {
- this.multipleData.push(this.multipleSelection);
- if (this.multipleData.length && this.multipleSelection.length) {
- let arrData = [];
- console.log(this.multipleData, "datga");
- for (let i = 0; i < this.multipleData.length; i++) {
- arrData = [...arrData, ...this.multipleData[i]];
- }
- if (this.goodsList.length) {
- this.goodsList = [...this.goodsList, ...arrData];
- } else {
- this.goodsList = arrData;
- }
- this.goodsList.forEach((item) => {
- this.$set(item, "status1", "");
- this.$set(item, "status2", "");
- });
- this.cusIndex = 0;
- this.total = 0;
- this.popDataArr = [];
- this.multipleData = [];
- this.policyId = this.screenForm.policyId;
- this.isShowDialog = false;
- } else {
- this.$errorMsg("请选择");
- }
- },
- // 获取详情
- getDetail() {
- getDetail({ id: this.listItem.id }).then((res) => {
- let data = res.data;
- this.mainForm.date = data.theTime;
- this.mainForm.type = data.mainId;
- this.mainForm.remark = data.remark;
- data.retailOrderItemList.forEach((item) => {
- item.status1 = "";
- item.status2 = "";
- });
- this.goodsList = data.retailOrderItemList;
- });
- },
- // 获取销售政策
- getPolicyList() {
- policyList({
- pageNum: 1,
- pageSize: -1,
- status: true,
- }).then((res) => {
- this.screenForm.policyId = res.data.records[0].code;
- this.handlePolicy(this.screenForm.policyId);
- this.policyList = res.data.records;
- console.log(this.policyList, "policyList");
- });
- },
- // 获取销售类型
- getTypeList() {
- const params = {
- pageNum: 1,
- pageSize: -1,
- saleCode: "",
- saleName: "",
- status: "",
- };
- typeList(params).then((res) => {
- this.ztypeList = res.data.records;
- console.log(this.ztypeList, "type1111");
- });
- },
- // 获取仓库列表
- getWarehouseList() {
- getWarehouseList({
- pageNum: 1,
- pageSize: -1,
- }).then((res) => {
- this.warehouseList = res.data.records;
- });
- },
- // 获取限定机型
- getpolicyTypeList() {
- getpolicyTypeList({
- pageNum: 1,
- pageSize: 10,
- policyId: this.screenForm.policyId,
- saleTypeCode: this.screenForm.saleTypeCode,
- }).then((res) => {
- for (let i = 0; i < res.data.records.length; i++) {
- res.data.records[i].qty = 1;
- }
- this.dataList = res.data.records;
- this.total = res.data.total;
- console.log(this.dataList, "kkkk");
- });
- },
- // 获取政策列表
- getMaterialTypeList() {
- getMaterialTypeList({
- pageNum: 1,
- pageSize: 10,
- policyId: this.screenForm.policyId,
- saleTypeCode: this.screenForm.saleTypeCode,
- }).then((res) => {
- for (let i = 0; i < res.data.records.length; i++) {
- res.data.records[i].qty = 1;
- }
- this.dataList = res.data.records;
- this.total = res.data.total;
- console.log(this.dataList, "kkkk");
- });
- },
- handleShow() {
- this.isShowDialog = true;
- this.getPolicyList();
- },
- // 获取钱包列表
- getWalletList() {
- getWalletList({
- customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
- type: "COMMONLY",
- }).then((res) => {
- this.xjWalletList = res.data;
- });
- getWalletList({
- customerId: JSON.parse(localStorage.getItem("supply_user")).customerId,
- type: "REBATE",
- }).then((res) => {
- this.flWalletList = res.data;
- });
- },
- // 获取销售类型列表
- getSalesTypeList() {
- getSalesTypeList({
- pageNum: 1,
- pageSize: -1,
- }).then((res) => {
- this.salesTypeList = res.data.records;
- });
- },
- getDictList() {
- getDictList({ sysDictEnum: "PRODUCT_TYPE" }).then((res) => {
- this.typeList = res.data;
- });
- },
- // 获取商品列表
- getGoodsList() {
- getGoodsList({
- pageNum: this.currentPage,
- pageSize: 10,
- mainId: this.screenForm.type,
- saleId: this.screenForm.salesType,
- materialCode: this.screenForm.proNum,
- materialName: this.screenForm.proName,
- specification: this.screenForm.proModel,
- price1: this.screenForm.price1,
- price2: this.screenForm.price2,
- }).then((res) => {
- let oldGoodsList = this.goodsList;
- let newGoodsList = res.data.records;
- for (let i = 0; i < oldGoodsList.length; i++) {
- let oldItem = oldGoodsList[i];
- for (let j = 0; j < newGoodsList.length; j++) {
- let newItem = newGoodsList[j];
- if (newItem.materialId === oldItem.materialId) {
- newGoodsList[j].selected = true;
- break;
- }
- }
- }
- res.data.records.forEach((item) => {
- item.materialName = item.name;
- item.materialCode = item.number;
- item.saleTypeName = item.saleName;
- item.unit = item.baseUnit;
- item.price = item.batchPrice;
- item.tax = item.taxRate;
- item.isDirectTransfer = false;
- item.directTransferQty = "";
- item.status1 = "";
- item.status2 = "";
- item.rebateAmount = "";
- item.rebateRate = "";
- item.productPriceId = item.id;
- });
- this.leftGoodsList = res.data.records;
- this.listTotal = res.data.total;
- });
- },
- // 查询重复值并禁选
- checkboxSelect(row, rowIndex) {
- if (row.selected) {
- return false; // 禁用
- } else {
- return true; // 不禁用
- }
- },
- // 点击 选择商品
- openDialog() {
- this.getSalesTypeList();
- this.getGoodsList();
- this.isShowDialog = true;
- },
- // 提交筛选表单
- submitScreenForm() {
- this.currentPage = 1;
- this.getGoodsList();
- },
- // 重置筛选表单
- resetScreenForm() {
- this.$refs.screenForm.resetFields();
- this.currentPage = 1;
- this.getGoodsList();
- },
- // 关闭 弹窗
- closeDialog() {
- this.isShowDialog = false;
- },
- // 删除
- deleteGoods() {
- let rightGoodsList = this.rightGoodsList;
- let rightSelection = this.rightSelection;
- for (let i = 0; i < rightGoodsList.length; i++) {
- for (let j = 0; j < rightSelection.length; j++) {
- if (rightSelection[j].materialId == rightGoodsList[i].materialId) {
- this.rightGoodsList.splice(i, 1);
- }
- }
- }
- },
- // 确定 添加产品
- submitAddGoods() {
- if (this.radio) {
- const params = this.radio.split("&");
- this.screenForm.policyId = params[1];
- this.mainForm.policyId = params[1];
- this.cusIndex += 1;
- getpolicyList({
- materialId: params[2],
- policyId: params[1],
- }).then((res) => {
- this.pop = res.data.pop;
- this.popArr = res.data.pop.split(":");
- this.popArr.splice(0, 1);
- for (let i = 0; i < this.popArr.length; i++) {
- this.$set(this.radioObj, "radio" + (i + 1), "");
- }
- this.step = this.cusIndex + 1;
- this.getConditionList(params[3], this.step);
- });
- } else {
- this.$errorMsg("请选择");
- }
- },
- // 更改每页数量
- handleSizeChange(val) {
- this.pageSize = val;
- this.currentPage = 1;
- this.getConditionList(this.policyConditionId, this.cusIndex + 1);
- },
- // 更改当前页
- handleCurrentChange(val) {
- this.currentPage = val;
- this.getConditionList(this.policyConditionId, this.cusIndex + 1);
- },
- // 更改列表当前页
- handleTableCurrentChange(val) {
- this.currentPage = val;
- this.getConditionList(this.policyConditionId, this.cusIndex + 1);
- },
- handleClose() {
- this.cusIndex = 0;
- this.radio = "";
- this.dataList = [];
- this.popDataArr = [];
- this.screenForm.policyId = "";
- this.screenForm.saleTypeCode = "";
- },
- // 删除产品
- deleteItem(index) {
- this.goodsList.splice(index, 1);
- console.log(this.multipleData);
- // this.popDataArr.splice(index,1)
- },
- // 修改返利钱包
- changeWallet(index) {
- if (this.goodsList[index].customerWalletId2) {
- let obj = this.flWalletList.find(
- (o) => o.customerWalletId == this.goodsList[index].customerWalletId2
- );
- this.goodsList[index].rebateRate = obj.rebateRate;
- } else {
- this.goodsList[index].rebateRate = "";
- }
- },
- // 检查库存
- checkStock() {
- if (!this.warehouseValue) {
- return this.$errorMsg("请选择仓库");
- }
- if (!this.goodsList) {
- return this.$errorMsg("请添加货品");
- }
- let ids = [];
- this.goodsList.forEach((item) => {
- ids.push(item.materialId);
- });
- checkStock({
- correspondId: this.warehouseValue,
- materialId: ids.join(","),
- }).then((res) => {
- if (res.data) {
- this.goodsList.forEach((item, index) => {
- item.status1 = res.data[index].allStockNum;
- item.status2 = res.data[index].stockNum;
- console.log(item.status1, item.status2);
- });
- }
- });
- },
- status2Filter(item) {
- if (
- item.status2 === "" ||
- item.status2 === null ||
- item.status2 === undefined
- )
- return "未检查";
- else if (item.status2 >= item.qty) return "可用";
- else return "短缺";
- },
- // 保存
- clickSubmitForm() {
- this.$refs.mainForm.validate((valid) => {
- if (valid) {
- // let mainName =
- // this.typeList[
- // findElem(this.typeList, "dictCode", this.mainForm.type)
- // ].dictValue;
- let params = {
- theTime: this.mainForm.date,
- mainId: this.mainForm.type,
- mainName:'',
- remark: this.mainForm.remark,
- type: 2, // 1:普通零售单,2:政策零售单
- retailOrderItemList: this.goodsList,
- policyId: this.policyId,
- };
- if (this.listItem) {
- params.id = this.listItem.id;
- editData(params).then((res) => {
- this.$successMsg("编辑成功");
- this.goBack();
- this.$parent.getList();
- });
- } else {
- addData(params).then((res) => {
- this.$successMsg("添加成功");
- this.goBack();
- this.$parent.getList();
- });
- }
- }
- });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .fr {
- margin: 10px;
- overflow: hidden;
- }
- .detail-container {
- width: 100%;
- height: 100%;
- }
- .main-title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 20px;
- height: 60px;
- border-bottom: 1px solid #dcdfe6;
- margin-bottom: 20px;
- .title {
- font-size: 16px;
- font-weight: 600;
- padding-left: 10px;
- }
- }
- .tables {
- display: flex;
- margin-top: 10px;
- .table {
- width: 45%;
- }
- .buttons {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- padding: 0 10px;
- button {
- margin: 0;
- margin-top: 10px;
- }
- }
- }
- .ellipsis {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- </style>
|