123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170 |
- <template>
- <div class="main-contain">
- <div class="position">
- <bread-crumb :crumbs="crumbs"></bread-crumb>
- </div>
- <div class="app-container" v-loading="loading">
- <div
- style="
- justify-content: space-between;
- margin: 0px 0 12px 0;
- display: flex;
- align-items: center;
- "
- >
- <div style="display:flex;align-items: center;">
- <span style="color: red">*</span><span>供应商:</span>
- <el-select
- v-model="supplier_name"
- style="width: 140px; margin-right: 10px"
- placeholder="请选择"
- @change="changeTypeName"
- :disabled="disabled"
- >
- <el-option
- v-for="item in supplyList"
- :key="item.id"
- :label="item.supplier_name"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <span>单据日期:</span>
- <el-date-picker
- size="small"
- v-model="start_time"
- prefix-icon="el-icon-date"
- :editable="false"
- style="width: 196px"
- type="date"
- placeholder="选择日期时间"
- align="right"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- :disabled="disabled"
- ></el-date-picker>
- <span>交货日期:</span>
- <el-date-picker
- size="small"
- v-model="end_time"
- prefix-icon="el-icon-date"
- :editable="false"
- style="width: 196px"
- type="date"
- placeholder="选择日期时间"
- align="right"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- @change="endTimeChange"
- :disabled="disabled"
- ></el-date-picker>
- <span>单据编码:{{ number }}</span>
- </div>
- <div style="display: flex;">
- <el-button size="small" type="primary" @click="toAdd" v-show="showOne"
- >生成采购单</el-button
- >
- <el-button size="small" type="primary" @click="updatePurchaseOrder"
- >保存</el-button
- >
- <el-button size="small" type="primary" @click="toPrint"
- >打印</el-button
- >
- <el-button
- size="small"
- type="primary"
- v-if="is_check == 2"
- @click="checkPurchaseOrder"
- v-show="showTwo"
- >审核</el-button
- >
- <el-button
- size="small"
- type="primary"
- v-if="is_check == 1"
- @click="checkReturnOrder"
- v-show="showThree"
- >反审核</el-button
- >
- </div>
- </div>
-
- <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
- <el-table
- :row-style="{ color: '#303133' }"
- :header-cell-style="{
- backgroundColor: 'rgb(245, 247, 250)',
- color: '#606266',
- }"
- :data="recordInfo.tableList"
- :class="signAndWeighBoxPatients"
- border
- style="width: 100%"
- max-height="450"
- >
- <el-table-column align="center" width="200px">
- <template slot="header" slot-scope="scope">
- <span>商品<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
- <el-form-item
- :prop="'tableList.' + scope.$index + '.name'"
- :rules="tableRules.name"
- >
- <el-select
- v-model="scope.row.name"
- style="width: 160px"
- filterable
- placeholder="请选择"
- @change="changeName"
- @input="changeGoodName(scope.$index)"
- :disabled="disabled"
- >
- <el-option
- v-for="(item, index) in tabList"
- :key="index"
- :label="item.supply_name"
- :value="item"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column align="center" width="150px">
- <template slot="header" slot-scope="scope">
- <span>商品类别</span>
- </template>
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_type"
- style="width: 120px"
- :disabled="true"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
- <el-table-column label="规格&单位" align="center" width="200px">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_specification_name"
- style="width: 150px"
- :disabled="true"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
- <el-table-column label="单位" align="center" width="120px">
- <template slot="header" slot-scope="scope">
- <span>单位<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
- <el-form-item
- :prop="'tableList.' + scope.$index + '.supply_unit'"
- :rules="tableRules.supply_unit"
- >
- <el-select
- v-model="scope.row.supply_unit"
- style="width: 100px"
- filterable
- placeholder="请选择"
- :disabled="disabled"
- >
- <el-option
- v-for="(item, index) in scope.row.unitList"
- :key="index"
- :label="item.name"
- :value="item.name"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </template>
- </el-table-column>
-
- <el-table-column label="可用库存" align="center" width="130px">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_total"
- style="width: 100px"
- :disabled="true"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
- <el-table-column label="数量" align="center" width="180px">
- <template slot="header" slot-scope="scope">
- <span>数量<span style="color: red">*</span></span>
- </template>
- <template slot-scope="scope">
- <el-form-item
- :prop="'tableList.' + scope.$index + '.supply_count'"
- :rules="tableRules.supply_count"
- >
- <el-input
- v-model="scope.row.supply_count"
- style="width: 140px"
- :disabled="disabled"
- placeholder="请输入数量"
- ></el-input>
- </el-form-item>
- </template>
- </el-table-column>
-
- <el-table-column label="采购单价" align="center" width="120px">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_price"
- style="width: 80px"
- :disabled="disabled"
- placeholder="请输入采购单价"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
-
- <el-table-column label="采购金额" align="center" width="120px">
- <template slot-scope="scope">
- {{ calculate(scope.row.supply_count * scope.row.supply_price) }}
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
-
- <el-table-column label="生产厂家" align="center" width="200px">
- <template slot-scope="scope">
- <el-select
- size="small"
- v-model="scope.row.supply_manufacturer"
- filterable
- :disabled="true"
- >
- <el-option
- v-for="(option, index) in manufactuerList"
- :key="index"
- :label="option.manufacturer_name"
- :value="option.id"
- >
- </el-option>
- </el-select>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
-
- <el-table-column label="批准文号" align="center" width="200px">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_license_number"
- style="width: 160px"
- :disabled="true"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
-
- <el-table-column label="备注" align="center" width="200px">
- <template slot-scope="scope">
- <el-input
- v-model="scope.row.supply_remake"
- style="width: 160px"
- :disabled="disabled"
- placeholder="请输入备注"
- ></el-input>
- <div style="visibility: hidden">/</div>
- </template>
- </el-table-column>
-
- <el-table-column
- label="操作"
- align="center"
- width="150px"
- fixed="right"
- >
- <template slot-scope="scope">
- <el-tooltip
- class="item"
- effect="dark"
- content="新增"
- placement="top"
- >
- <el-button
- size="mini"
- type="primary"
- icon="el-icon-circle-plus-outline"
- @click="handleEdit(scope.$index, scope.row)"
- >
- </el-button>
- </el-tooltip>
- <el-tooltip
- class="item"
- effect="dark"
- content="删除"
- placement="top"
- >
- <el-button
- size="mini"
- type="danger"
- icon="el-icon-delete"
- @click="handleDelete(scope.$index, scope.row)"
- >
- </el-button>
- </el-tooltip>
- </template>
- </el-table-column>
- </el-table>
- <div style="margin-top: 10px">
- <el-input
- type="textarea"
- :rows="2"
- placeholder="备注信息"
- v-model="return_remark"
- :disabled="disabled"
- >
- </el-input>
- </div>
- <!-- 审核水印 -->
- <img
- src="@/assets/purchase/Reviewed.png"
- alt="正在加载..."
- class="reviewImg"
- v-show="Reviewed == true"
- />
- </el-form>
- <div style="margin-top: 10px">合计:{{ getAllPrice() }} 元</div>
- <div style="margin-top: 10px">
- <span
- >优惠率:<el-input
- style="width: 150px"
- v-model="rate_of_concession"
- @input="addressChange"
- :disabled="disabled"
- placeholder="请输入优惠率"
- ></el-input
- >%</span
- >
-
- <span
- >优惠金额:<el-input
- style="width: 150px"
- v-model="discount_amount"
- :disabled="disabled"
- placeholder="请输入优惠金额"
- ></el-input
- ></span>
- </div>
- </div>
-
- <!-- <el-dialog
- title="系统提示"
- :visible.sync="dialogVisible"
- width="30%">
- <span>
- 采购订单{{number}}已有以下关联数据,不能反审核
- <div v-for="(item,index) in orderList" :key="index">
- <li>采购单{{item.good_number}}</li> <a @click="toClick(item.id)">点击查看</a>
- </div>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- </span>
- </el-dialog> -->
- <popup ref="Popup" :content="content" :content_1="content_1" :content_2="content_2" :number="number" :orderList ="orderList" :type="type"></popup>
- </div>
- </template>
-
- <script>
- import popup from "./Popup"
- import BreadCrumb from "@/xt_pages/components/bread-crumb";
- import { uParseTime } from "@/utils/tools";
- import {
- getInitOrder,
- updatePurchaseOrder,
- checkPurchaseOrder,
- getPurchaseOrderDetail,
- getAllOrderCountList,
- getGoodOrderList,
- getReturnOrder,
- deletePurchaseOrder,
- deletePurchOder
- } from "@/api/supply";
- export default {
- name: "addPurchaseOrder",
- components: {
- BreadCrumb,
- popup
- },
- data() {
- return {
- content_2:"采购单",
- content:"采购订单",
- content_1:"已有以下关联数据,不能反审核",
- type:1,
- Reviewed: false,
- crumbs: [
- { path: false, name: "采购订单" },
- { path: "/supply/query", name: "编辑采购订单" },
- ],
- showTwo: true,
- showOne: false,
- recordInfo: {
- tableList: [],
- },
- keywords: "",
- total: 0,
- multipleSelection: [],
- signAndWeighBoxPatients: "sign-and-weigh-box-patients",
- start_time: "",
- end_time: "",
- page: 1,
- limit: 10,
- goodType: [],
- goodInfo: [],
- org_id: 0,
- types: [],
- tyep_name: "",
- form: {
- manufacturer_id: "",
- },
- tabList: [],
- manufactuerList: [],
- currentIndex: 0,
- goodTypeList: [],
- drugTypeList: [],
- supplier_name: "",
- supplyList: [],
- rate_of_concession: "",
- discount_amount: "",
- tableRules: {
- name: [{ required: true, message: "商品不能为空", trigger: "blur" }],
- supply_count: [
- { required: true, message: "数量不能为空", trigger: "blur" },
- ],
- },
- warehousing_id: 0,
- number: "",
- loading: false,
- drugList: [],
- goodList: [],
- id: 0,
- disabled: false,
- is_check: 0,
- dialogVisible: false,
- total_price: 0,
- showOne: true,
- showTwo: true,
- showThree: false,
- orderList: [],
- return_remark: "",
-
- };
- },
- methods: {
- getInitOrder() {
- getInitOrder().then((response) => {
- if (response.data.state == 1) {
- var drugList = response.data.data.drugList;
- this.manufactuerList = response.data.data.manufactuerList;
- this.goodTypeList = response.data.data.goodTypeList;
- this.drugTypeList = response.data.data.drugTypeList;
- this.supplyList = response.data.data.supplyList;
- for (let i = 0; i < drugList.length; i++) {
- for (let z = 0; z < drugList[i].drug_warehouse_info.length; z++) {
- if (
- drugList[i].max_unit ==
- drugList[i].drug_warehouse_info[z].max_unit
- ) {
- drugList[i].drug_warehouse_info[z].stock_max_number =
- drugList[i].drug_warehouse_info[z].stock_max_number *
- drugList[i].min_number;
- }
- }
- for (let j = 0; j < this.manufactuerList.length; j++) {
- if (drugList[i].manufacturer == this.manufactuerList[j].id) {
- drugList[i].manufacturer =
- this.manufactuerList[j].manufacturer_name;
- }
- }
- for (let y = 0; y < this.drugTypeList.length; y++) {
- if (drugList[i].drug_type == this.drugTypeList[y].value) {
- drugList[i].drug_type = this.drugTypeList[y].name;
- }
- }
- drugList[i].supply_name =
- drugList[i].drug_name +
- " " +
- drugList[i].dose +
- drugList[i].dose_unit +
- "*" +
- drugList[i].min_number +
- drugList[i].min_unit +
- "/" +
- drugList[i].max_unit +
- " " +
- drugList[i].manufacturer;
- drugList[i].supply_type = drugList[i].drug_type;
- drugList[i].supply_specification_name =
- drugList[i].dose +
- drugList[i].dose_unit +
- "*" +
- drugList[i].min_number +
- drugList[i].min_unit +
- "/" +
- drugList[i].max_unit;
- drugList[i].supply_total = this.getWarehoseInfo(
- drugList[i].drug_warehouse_info,
- drugList[i].max_unit,
- drugList[i].min_unit,
- drugList[i].min_number
- );
- drugList[i].supply_count = "";
- drugList[i].supply_total_price = "";
- drugList[i].supply_manufacturer = drugList[i].manufacturer;
- drugList[i].supply_license_number = drugList[i].number;
- drugList[i].supply_remake = "";
- drugList[i].type = 1;
- drugList[i].supply_price = drugList[i].last_price;
- drugList[i].name = drugList[i].drug_name;
- if (drugList[i].max_unit != drugList[i].min_unit) {
- drugList[i].unitList = [
- { id: 1, name: "" },
- { id: 2, name: "" },
- ];
- }
- if (drugList[i].max_unit == drugList[i].min_unit) {
- drugList[i].unitList = [{ id: 1, name: "" }];
- }
-
- drugList[i].supply_unit = drugList[i].max_unit;
- for (let j = 0; j < drugList[i].unitList.length; j++) {
- if (drugList[i].max_unit != drugList[i].min_unit) {
- drugList[i].unitList[0].name = drugList[i].max_unit;
- drugList[i].unitList[1].name = drugList[i].min_unit;
- }
- if (drugList[i].max_unit == drugList[i].min_unit) {
- drugList[i].unitList[0].name = drugList[i].max_unit;
- }
- }
- this.tabList.push(drugList[i]);
- }
- this.drugList = drugList;
- var goodList = response.data.data.goodList;
- for (let i = 0; i < goodList.length; i++) {
- for (let j = 0; j < this.manufactuerList.length; j++) {
- if (goodList[i].manufacturer == this.manufactuerList[j].id) {
- goodList[i].manufacturer =
- this.manufactuerList[j].manufacturer_name;
- }
- }
- for (let y = 0; y < this.goodTypeList.length; y++) {
- if (goodList[i].good_type_id == this.goodTypeList[y].id) {
- goodList[i].good_type_id = this.goodTypeList[y].type_name;
- }
- }
- goodList[i].supply_name =goodList[i].good_name +" " +goodList[i].specification_name +" " + goodList[i].manufacturer;
- goodList[i].supply_type = goodList[i].good_type_id;
- goodList[i].supply_specification_name =goodList[i].specification_name;
- goodList[i].supply_price = goodList[i].buy_price;
- goodList[i].supply_total = this.getTotalStockCount(goodList[i].good_warehouse_info);
- goodList[i].supply_count = "";
- goodList[i].supply_total_price = "";
- goodList[i].supply_manufacturer = goodList[i].manufacturer;
- goodList[i].supply_license_number = goodList[i].number
- goodList[i].supply_remake = "";
- goodList[i].type = 2;
- goodList[i].name = goodList[i].good_name;
- goodList[i].unitList = [{ id: 1, name: "" }];
- goodList[i].supply_unit = goodList[i].packing_unit;
- for (let j = 0; j < goodList[i].unitList.length; j++) {
- goodList[i].unitList[0].name = goodList[i].packing_unit;
- }
- this.tabList.push(goodList[i]);
- }
- this.goodList = goodList;
-
- }
- });
- },
- changeGoodName(val) {
- this.currentIndex = val;
- },
- changeName(val) {
- for (let i = 0; i < this.recordInfo.tableList.length; i++) {
- if (this.currentIndex == i) {
- this.recordInfo.tableList[i].project_id = val.id;
- this.recordInfo.tableList[i].type = val.type;
- this.recordInfo.tableList[i].name = val.name;
- this.recordInfo.tableList[i].supply_name = val.supply_name;
- this.recordInfo.tableList[i].supply_type = val.supply_type;
- this.recordInfo.tableList[i].supply_specification_name =val.supply_specification_name;
- this.recordInfo.tableList[i].supply_total = val.supply_total;
- if (val.supply_count == NaN) {
- this.recordInfo.tableList[i].supply_count = "";
- } else {
- this.recordInfo.tableList[i].supply_count = val.supply_count
- ? val.supply_count
- : "";
- }
-
- this.recordInfo.tableList[i].supply_price = val.supply_price? val.supply_price: "";
- this.recordInfo.tableList[i].supply_total_price =val.supply_total_price ? val.supply_total_price : "";
- this.recordInfo.tableList[i].supply_manufacturer =val.supply_manufacturer;
- this.recordInfo.tableList[i].supply_license_number =val.supply_license_number;
- this.recordInfo.tableList[i].supply_remake = val.supply_remake;
- this.recordInfo.tableList[i].is_total = val.is_total;
- this.recordInfo.tableList[i].supply_unit = val.supply_unit;
- this.recordInfo.tableList[i].unitList = val.unitList;
- }
- }
- },
- handleEdit() {
- if (this.is_check == 1) {
- this.$message.error("已审核的不能新增!");
- return false;
- }
- const tempObj = {};
- tempObj["id"] = 0;
- tempObj["name"] = "";
- tempObj["supply_name"] = "";
- tempObj["supply_type"] = "";
- tempObj["supply_specification_name"] = "";
- tempObj["supply_total"] = "";
- tempObj["supply_count"] = "";
- tempObj["supply_price"] = "";
- tempObj["supply_total_price"] = "";
- tempObj["supply_manufacturer"] = "";
- tempObj["supply_license_number"] = "";
- tempObj["supply_remake"] = "";
- tempObj["type"] = 0;
- tempObj["is_total"] = 1;
- tempObj["project_id"] = 0;
- tempObj["supply_unit"] = "";
- tempObj["manufacturer_id"] = "";
- this.recordInfo.tableList.push(tempObj);
- },
- handleDelete: function (index, row) {
-
- if(this.is_check == 1){
- this.$message.error("已审核单据,不能删除!")
- return false
- }
- if(row.id == 0){
- if (this.recordInfo.tableList.length <= 1) {
- this.$message.error("只有一条记录的时候无法删除");
- return;
- } else {
- this.recordInfo.tableList.splice(index, 1);
- }
- }else{
- const params = {
- id: row.id
- }
- this.$confirm('确认删除吗?', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- deletePurchOder(params).then(response => {
- if (response.data.state == 0) {
- this.$message.error(response.data.msg)
- return false
- } else {
- this.$message.success('删除成功')
-
- this.recordInfo.tableList.splice(index, 1)
- }
- })
- }).catch(() => {
- })
-
- }
-
- },
-
- changeTypeName() {},
- startTimeChange() {},
- endTimeChange() {},
- search() {},
-
- getWarehoseInfo(arr, max_unit, min_unit, min_number) {
- var total = 0;
- var max_str = "";
- var min_str = "";
- if (arr.length > 0) {
- for (let i = 0; i < arr.length; i++) {
- total += parseInt(arr[i].stock_max_number + arr[i].stock_min_number);
- }
- }
- if (total < min_number) {
- min_str = total + min_unit;
- }
- if (total == 0) {
- min_str = "";
- max_str = "";
- }
- if (total >= min_number) {
- if (parseInt(total / min_number) != 0) {
- max_str = parseInt(total / min_number) + max_unit;
- }
- if (total % min_number != 0) {
- min_str = (total % min_number) + min_unit;
- }
- }
- return max_str + min_str;
- },
- getTotalStockCount(arr) {
- var total_count = 0;
- for (let i = 0; i < arr.length; i++) {
- total_count += arr[i].stock_count;
- }
- return total_count;
- },
- calculate: function (val) {
- if (isNaN(val)) {
- return "";
- }
- if (val == 0) {
- return "";
- }
- return Math.round(parseFloat(val) * 100) / 100;
- },
- getTimes(time) {
- if (time === "") {
- return "";
- }
- return uParseTime(time, "{y}-{m}-{d}");
- },
- updatePurchaseOrder() {
- if (this.supplier_name == 0 || this.supplier_name == "") {
- this.$message.error("供应商不能为空!");
- this.loading = false;
- return false;
- }
- this.$refs["tableForm"].validate((valid) => {
- if (valid) {
- this.loading = true;
-
- for (let i = 0; i < this.recordInfo.tableList.length; i++) {
- this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count);
- this.recordInfo.tableList[i].supply_license_number =this.recordInfo.tableList[i].supply_license_number.toString();
- this.recordInfo.tableList[i].supply_total_price = (this.recordInfo.tableList[i].supply_count *this.recordInfo.tableList[i].supply_price).toString();
- this.recordInfo.tableList[i].supply_total =this.recordInfo.tableList[i].supply_total.toString();
- this.recordInfo.tableList[i].supply_price = this.recordInfo.tableList[i].supply_price.toString();
- for (let j = 0; j < this.manufactuerList.length; j++) {
- if (
- this.recordInfo.tableList[i].supply_manufacturer ==
- this.manufactuerList[j].id
- ) {
- this.recordInfo.tableList[i].supply_manufacturer =
- this.manufactuerList[j].manufacturer_name;
- }
- if (
- this.recordInfo.tableList[i].supply_manufacturer ==
- this.manufactuerList[j].manufacturer_name
- ) {
- this.recordInfo.tableList[i].manufacturer_id =
- this.manufactuerList[j].id;
- }
- }
- }
- var start = this.start_time;
- var end = this.end_time;
- const params = {
- stockIn: this.recordInfo.tableList,
- return_remake: this.return_remark,
- };
-
-
- updatePurchaseOrder(
- params,
- this.supplier_name,
- start,
- end,
- this.rate_of_concession,
- this.discount_amount,
- this.id,
- this.number
- ).then((response) => {
- if (response.data.state == 1) {
- this.loading = false;
- var warehousingInfo = response.data.data.warehousingInfo;
- this.$message.success("保存成功!");
- }
- });
- }
- });
- },
-
- getAllPrice() {
- var total_price = 0;
- for (let i = 0; i < this.recordInfo.tableList.length; i++) {
- total_price +=
- this.recordInfo.tableList[i].supply_price *
- this.recordInfo.tableList[i].supply_count;
- }
- this.total_price = total_price;
- this.addressChange()
- return total_price.toFixed(2);
- },
-
- checkPurchaseOrder(id, index) {
- this.$confirm("是否审核?", {
- confirmButtonText: "确 定",
- cancelButtonText: "取 消",
- type: "warning",
- }).then(() => {
- checkPurchaseOrder(this.id).then((response) => {
- if (response.data.state == 1) {
- var info = response.data.data.info;
- this.disabled = true;
- this.$message.success("审核成功!");
- this.showOne = true;
- this.showTwo = false;
- this.showThree = true;
- this.getPurchaseOrderDetail();
- }
- });
- })
- .catch(() => {});
- },
- getPurchaseOrderDetail() {
- var id = this.$route.query.id;
- getPurchaseOrderDetail(id).then((response) => {
- if (response.data.state == 1) {
- var info = response.data.data.info;
- if (info.is_check == 1) {
- this.Reviewed = true;
- }
- this.is_check = info.is_check;
- this.number = info.number;
- this.return_remark = info.return_remake;
- this.id = info.id;
- this.supplier_name = info.supplier_id;
- this.rate_of_concession = info.rate_of_concession;
- this.discount_amount = info.discount_amount;
- this.start_time = this.getTimes(info.document_date);
- this.end_time = this.getTimes(info.delivery_date);
- var orderInfo = response.data.data.orderInfo;
-
- if (info.is_check == 2) {
- this.disabled = false;
- this.showOne = false;
- this.showTwo = true;
- this.showThree = false;
- }
- if (info.is_check == 1) {
- this.disabled = true;
- this.showOne = true;
- this.showTwo = false;
- this.showThree = true;
- }
-
- var drugList = response.data.data.baseList;
- var goodList = response.data.data.goodList;
- for (let i = 0; i < orderInfo.length; i++) {
- orderInfo[i].supply_count = orderInfo[i].count;
- orderInfo[i].supply_price = orderInfo[i].price;
- orderInfo[i].supply_remake = orderInfo[i].remark;
- orderInfo[i].type = orderInfo[i].is_source;
- orderInfo[i].project_id = orderInfo[i].project_id;
- orderInfo[i].supply_unit = orderInfo[i].supply_unit;
- if (orderInfo[i].is_source == 1) {
- for (let j = 0; j < drugList.length; j++) {
- if (orderInfo[i].project_id == drugList[j].id) {
- if (drugList[j].max_unit != drugList[j].min_unit) {
- orderInfo[i].unitList = [
- { id: 1, name: "" },
- { id: 2, name: "" },
- ];
- orderInfo[i].unitList[0].name = drugList[j].max_unit;
- orderInfo[i].unitList[1].name = drugList[j].min_unit;
- }
- if (drugList[j].max_unit == drugList[j].min_unit) {
- orderInfo[i].unitList = [{ id: 1, name: "" }];
- orderInfo[i].unitList[0].name = drugList[j].max_unit;
- }
- }
- }
- }
- if (orderInfo[i].is_source == 2) {
- for (let j = 0; j < goodList.length; j++) {
- if (orderInfo[i].project_id == goodList[j].id) {
- orderInfo[i].unitList = [{ id: 1, name: "" }];
- orderInfo[i].unitList[0].name = goodList[j].packing_unit;
- }
- }
- }
- }
-
- this.recordInfo.tableList = [];
- if(orderInfo.length == 0){
- const tempObj = {};
- tempObj["id"] = 0;
- tempObj["name"] = "";
- tempObj["supply_name"] = "";
- tempObj["supply_type"] = "";
- tempObj["supply_specification_name"] = "";
- tempObj["supply_total"] = "";
- tempObj["supply_count"] = "";
- tempObj["supply_price"] = "";
- tempObj["supply_total_price"] = "";
- tempObj["supply_manufacturer"] = "";
- tempObj["supply_license_number"] = "";
- tempObj["supply_remake"] = "";
- tempObj["type"] = 0;
- tempObj["is_total"] = 1;
- tempObj["project_id"] = 0;
- tempObj["supply_unit"] = "";
- tempObj["manufacturer_id"] = "";
- this.recordInfo.tableList.push(tempObj);
- }else{
- this.recordInfo.tableList = orderInfo;
- }
-
- }
- });
- },
- toPrint() {
- var id = this.$route.query.id;
- this.$router.push({ path: "/purchase/order/print?&id=" + id });
- },
- toAdd() {
- var id = this.$route.query.id;
- if (this.is_check == 2) {
- this.$message.error("该采购订单未审核,不能生成采购数据!");
- return false;
- }
- //获取商品购货订单 和 购货单的总数量
- getAllOrderCountList(id).then((response) => {
- if (response.data.state == 1) {
- var purcaseOrder = response.data.data.purcaseOrder;
-
- var goodOrder = response.data.data.goodOrder;
-
- var drugList = response.data.data.drugList;
-
- var ids = "";
- // 如果采购单没有数据,则代表改订单第一次生成采购订单数据
- if (goodOrder.length == 0) {
- this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + ids});
- }
- for (let i = 0; i < purcaseOrder.length; i++) {
- for (let j = 0; j < drugList.length; j++) {
- if (purcaseOrder[i].is_source == 1) {
- if (purcaseOrder[i].supply_unit == drugList[j].max_unit) {
- purcaseOrder[i].count = purcaseOrder[i].count * drugList[j].min_number;
- }
- }
- }
- }
-
- for (let i = 0; i < goodOrder.length; i++) {
- for (let j = 0; j < drugList.length; j++) {
- if (goodOrder[i].is_source == 1) {
- if (goodOrder[i].supply_unit == drugList[j].max_unit) {
- goodOrder[i].count = goodOrder[i].count * drugList[j].min_number;
- }
- }
- }
- }
-
- let objInfo = {};
- if (goodOrder.length > 0) {
- goodOrder.forEach((item, index) => {
- let { project_id } = item;
- if (!objInfo[project_id]) {
- objInfo[project_id] = {
- project_id,
- child: [],
- count: 0,
- };
- }
- });
- let newArr = Object.values(objInfo);
-
- for (let i = 0; i < goodOrder.length; i++) {
- for (let j = 0; j < newArr.length; j++) {
- if (goodOrder[i].project_id == newArr[j].project_id) {
- newArr[j].child.push(goodOrder[i]);
- }
- }
- }
-
-
- for (let i = 0; i < newArr.length; i++) {
- for (let j = 0; j < newArr[i].child.length; j++) {
- newArr[i].count += newArr[i].child[j].count;
- }
- }
-
- var arr = [];
- var total = 0;
- var str = "";
-
- //如果采购单有数据,则需要比较数量
- if (newArr.length > 0) {
- for (let i = 0; i < purcaseOrder.length; i++) {
- for (let j = 0; j < newArr.length; j++) {
- if (purcaseOrder[i].project_id == newArr[j].project_id) {
- //根据商品ID比较数量大小,把数量不足的商品ID储存,表示采购单的数量未满足采购订单的数据,可以继续生成采购单
- if (purcaseOrder[i].count > newArr[j].count) {
- arr.push(purcaseOrder[i].project_id);
- }
- }
- }
- }
- //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
-
- if (arr.length == 0) {
- this.$message.error("该订单已全部生成采购单,请知悉!");
- return;
- }
-
- if (arr.length >0) {
- str = arr.join(",");
- this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + str});
- }
- }
- }
- }
- });
- },
- addressChange() {
- if (this.rate_of_concession > 0) {
- this.discount_amount = (
- (this.rate_of_concession / 100) *
- this.total_price
- ).toFixed(2);
- }
- },
- checkReturnOrder() {
- var id = this.$route.query.id;
- //获取购货订单号
- getGoodOrderList(id).then((response) => {
- if (response.data.state == 1) {
- var list = response.data.data.list
-
- this.orderList = list
- //如果长度大于0,有购货单不能反审核
- if (list.length > 0) {
- this.$refs.Popup.dialogVisible = true
- return
- }
- if (list.length == 0) {
- this.getReturnOrder()
- this.showOne = false
- this.showTwo = true
- this.showThree = false
- }
- }
- });
- },
- getReturnOrder() {
- var id = this.$route.query.id;
- getReturnOrder(id).then((response) => {
- if (response.data.state == 1) {
- var msg = response.data.data.msg;
- this.disabled = false;
- this.Reviewed = false
- this.$message.success("反审核成功!");
- this.getPurchaseOrderDetail();
- }
- });
- },
- toClick(id) {
- this.$router.push({path:"/good/order/edit?id=" + id});
- },
- },
- created() {
- const tempObj = {};
- tempObj["id"] = 0;
- tempObj["name"] = "";
- tempObj["supply_name"] = "";
- tempObj["supply_type"] = "";
- tempObj["supply_specification_name"] = "";
- tempObj["supply_total"] = "";
- tempObj["supply_count"] = "";
- tempObj["supply_price"] = "";
- tempObj["supply_total_price"] = "";
- tempObj["supply_manufacturer"] = "";
- tempObj["supply_license_number"] = "";
- tempObj["supply_remake"] = "";
- tempObj["type"] = 0;
- tempObj["is_total"] = 1;
- tempObj["project_id"] = 0;
- tempObj["supply_unit"] = "";
- tempObj["manufacturer_id"] = "";
- this.recordInfo.tableList.push(tempObj);
- this.getInitOrder();
- this.getPurchaseOrderDetail();
- },
- };
- </script>
-
- <style rel="stylesheet/css" lang="scss" scoped>
- .information {
- border: 1px #dcdfe6 solid;
- padding: 30px 20px 30px 20px;
-
- .border {
- border-bottom: 1px #dcdfe6 solid;
- margin: 0px 0 20px 0;
- }
- }
-
- .title {
- background: #409eff;
- height: 44px;
- line-height: 44px;
- padding: 0 0 0 10px;
- color: #fff;
- margin: 0 0 10px 0;
- }
-
- .edit_separater {
- border-top: 1px solid rgb(233, 233, 233);
- margin-top: 15px;
- margin-bottom: 15px;
- }
- /deep/ .el-table__body-wrapper::-webkit-scrollbar {
- width: 10px;
- height: 10px;
- }
- </style>
-
- <style>
- .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
- font-size: 12px;
- }
-
- .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
- background: #6fb5fa;
- }
-
- .count {
- color: #bd2c00;
- }
- .el-table td,
- .el-table th.is-leaf,
- .el-table--border,
- .el-table--group {
- border-color: #d0d3da;
- }
- .el-table--border::after,
- .el-table--group::after,
- .el-table::before {
- background-color: #d0d3da;
- }
- .el-table__fixed-right {
- width: 150px;
- bottom: 20px;
- height: 100%;
- }
- .reviewImg {
- position: fixed;
- left: 50%;
- transform: translateX(-50%);
- top: 30%;
- }
-
-
- </style>
|