123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- <template>
- <!-- 采购明细出库 -->
- <div>
- <div class="common-card">
- <el-form :model="listForm" ref="planForm" :inline="true">
- <el-form-item label="采购单号" prop="dyntNo">
- <el-input v-model="listForm.dyntNo" placeholder="请输入采购单号"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="getDetails('search')"
- >提取采购明细
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="common-card">
- <el-form :model="tableData" ref="tabledata">
- <el-table
- :data="tableData"
- v-loading="loding"
- element-loading-text="加载中..."
- border
- :span-method="handleSpan"
- >
- <template slot="empty">
- <img src="@/assets/nopage.png" alt />
- <p>暂无数据</p>
- </template>
- <el-table-column fixed type="index" label="序号" width="60" />
- <el-table-column label="采购单号" prop="purcOrdId" />
- <el-table-column label="耗材编码" prop="prodCode" />
- <el-table-column label="医保编码" prop="hiCode" />
- <el-table-column label="耗材信息" width="300">
- <template slot-scope="scope">
- <mcs-info :info="scope.row"></mcs-info>
- </template>
- </el-table-column>
- <el-table-column label="规格" prop="spec" />
- <el-table-column label="型号" prop="mol" />
- <el-table-column label="材质" prop="matl" />
- <el-table-column label="单价" prop="purcPric" />
- <el-table-column label="批号" prop="lotNum" width="120">
- <template slot-scope="scope">
- <el-form-item
- label-width="0"
- class="item"
- :prop="scope.$index + '.lotNum'"
- :rules="[
- {
- required: true,
- message: '请输入',
- trigger: 'blur',
- },
- ]"
- >
- <el-input placeholder="请输入" v-model="scope.row.lotNum"></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="生产日期" prop="manuDate" width="220">
- <template slot-scope="scope">
- <el-form-item
- label-width="0"
- class="item"
- :prop="scope.$index + '.manuDate'"
- :rules="[
- {
- required: true,
- message: '请选择生产日期',
- trigger: 'change',
- },
- ]"
- >
- <el-date-picker
- style="width: 100%"
- v-model="scope.row.manuDate"
- type="date"
- placeholder="请选择生产日期"
- value-format="yyyy-MM-dd"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="有效期至" width="220" prop="prodExpy">
- <template slot-scope="scope">
- <el-form-item
- label-width="0"
- class="item"
- :prop="scope.$index + '.prodExpy'"
- :rules="[
- {
- required: true,
- message: '请选择有效期',
- trigger: 'change',
- },
- ]"
- >
- <el-date-picker
- style="width: 100%"
- v-model="scope.row.prodExpy"
- type="date"
- placeholder="请选择有效期"
- value-format="yyyy-MM-dd"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="需求数量" prop="purcCnt" />
- <!-- <el-table-column label="已出库数量" prop="delvCntYck" width="90px" /> -->
- <el-table-column label="剩余出库量" prop="toDelvCnt" width="90px" />
- <el-table-column label="出库数量" prop="delvCnt" width="150">
- <template slot-scope="scope">
- <el-form-item
- label-width="0"
- class="item"
- :prop="scope.$index + '.delvCnt'"
- :rules="[
- {
- required: true,
- pattern: /^[0-9]\d*$/,
- message: '请输入正整数',
- trigger: 'blur',
- },
- ]"
- >
- <el-input-number
- v-model="scope.row.delvCnt"
- controls-position="right"
- @change="updateNum(scope.row, scope.$index)"
- :min="0"
- ></el-input-number>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column label="报关单" prop="invoFileId" width="200">
- <template slot-scope="scope">
- <yl-upload
- v-if="scope.row.prodSouc == '2'"
- :fileId="scope.row.invoFileId"
- @getUpload="getUpload1"
- urlName="acco"
- :index="scope.$index"
- >
- <template v-slot:dec>只能上传pdf文件</template>
- </yl-upload>
- </template>
- </el-table-column>
- <!-- <el-table-column label="随货单" prop="dyntFileId" width="200">
- <template slot-scope="scope">
- <yl-upload
- :fileId="scope.row.dyntFileId"
- @getUpload="getUpload"
- urlName="acco"
- :index="scope.$index"
- >
- <template v-slot:dec>只能上传pdf文件</template>
- </yl-upload>
- </template>
- </el-table-column> -->
- <el-table-column label="备注" prop="memo" width="120">
- <template slot-scope="scope">
- <el-form-item label-width="0" class="item">
- <el-input placeholder="请输入" v-model="scope.row.memo"></el-input>
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column align="center" fixed="right" label="操作" width="120">
- <template slot-scope="scope">
- <el-button
- v-if="scope.row.showDeleteButton"
- class="red"
- type="text"
- @click="handleDelete(scope.row, scope.$index)"
- >删除</el-button
- >
- <el-button v-else type="text" @click="handleBatch(scope.row, scope.$index)"
- >添加批次
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- </div>
- <div class="foot-button" style="margin-top: 30px">
- <!-- <el-button type="success" @click="handleSave">保存</el-button> -->
- <el-button type="primary" @click="handleDelivery">出库</el-button>
- </div>
- <el-dialog title="提取采购单" :visible.sync="dialog" width="70%">
- <template>
- <el-form :model="listQuery" ref="listQuery" :inline="true" label-width="90px">
- <el-form-item size="mini" label="采购单号" prop="purcOrdId" class="long">
- <el-input v-model="listQuery.purcOrdId" placeholder="请输入采购单号"></el-input>
- </el-form-item>
- <el-form-item size="mini" label="耗材名称" prop="prodName" class="long">
- <el-input
- v-model="listQuery.prodName"
- placeholder="请输入耗材名称"
- ></el-input>
- </el-form-item>
- <el-form-item size="mini" label="医保编码" prop="hiCode" class="long">
- <el-input v-model="listQuery.hiCode" placeholder="请输入医保编码"></el-input>
- </el-form-item>
- <el-form-item size="mini" label="生产企业" prop="prodEntp" class="long">
- <el-input v-model="listQuery.prodEntp" placeholder="请输入生产企业"></el-input>
- </el-form-item>
- <el-form-item size="mini" label="是否集采" prop="isFas" class="long">
- <el-select v-model="listQuery.isFas" placeholder="请选择是否集采" clearable>
- <el-option
- v-for="item in isFasData"
- :key="item.value"
- :label="item.name"
- :value="item.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item size="mini" label="注册证号" prop="regcertno" class="long">
- <el-input v-model="listQuery.regcertno" placeholder="请输入注册证号"></el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="getdialog('search')">查询</el-button>
- <el-button @click="reset('consumable')">重置</el-button>
- </el-form-item>
- </el-form>
- <el-table
- ref="multipleTable"
- v-loading="dialogLoading"
- element-loading-text="加载中"
- fit
- stripe
- border
- :data="consumableData"
- border
- style="width: 100%"
- row-key="id"
- height="500"
- @selection-change="handleSelectionChange"
- highlight-current-row
- :default-sort="{ prop: 'hiCode', order: 'descending' }"
- >
- <el-table-column
- type="selection"
- :reserve-selection="true"
- width="55"
- ></el-table-column>
- <el-table-column label="采购单号" prop="purcOrdId"> </el-table-column>
- <el-table-column label="耗材编码" prop="prodCode" />
- <el-table-column label="医保编码" prop="hiCode" />
- <el-table-column label="耗材信息" width="300">
- <template slot-scope="scope">
- <mcs-info :info="scope.row"></mcs-info>
- </template>
- </el-table-column>
- <el-table-column label="规格" prop="spec" />
- <el-table-column label="型号" prop="mol" />
- <el-table-column label="材质" prop="matl" />
- <el-table-column label="是否集采" prop="isFas">
- <template #default="{ row }">
- <span v-if="row.isFas == '1'">否</span>
- <span v-if="row.isFas == '0'">是</span>
- </template>
- </el-table-column>
- <el-table-column label="计价单位" prop="prcUnt" />
- <el-table-column label="采购单位" prop="purcUnt" />
- <el-table-column label="包装内数量" prop="convrat" />
- <el-table-column label="单价" prop="purcPric" />
- <el-table-column label="需求数量" prop="purcCnt" />
- <!-- <el-table-column label="已出库数量" prop="delvCntYck" width="90px" /> -->
- <el-table-column label="剩余出库量" prop="toDelvCnt" width="90px" />
- </el-table>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="handleConfirm">确认</el-button>
- </div>
- <!--分页-->
- <yl-pagination
- v-show="total > 0"
- :total="total"
- :page.sync="listQuery.current"
- :limit.sync="listQuery.size"
- @pagination="getdialog"
- />
- </template>
- </el-dialog>
- </div>
- </template>
- <script>
- import mcsInfo from "@/views/components/mcs-info.vue";
- import ylUpload from "@/components/yl-upload";
- import { countNumPrice, getTotalAmount } from "@/utils/utils";
- import rules from "@/utils/rules";
- import { getMcsPurcOrdMx, submitMcsDelvOrd } from "@/api/orderManage-sup/index";
- export default {
- components: {
- mcsInfo,
- ylUpload,
- },
- data() {
- return {
- rules,
- listForm: {
- dyntNo: "",
- current: 1,
- size: 10,
- },
- planForm: {},
- // 表格数据
- loding: false,
- tableData: [],
- // 弹框表格数据
- dialog: false,
- listQuery: {
- hiCode: "",
- prodName: "",
- purcOrdId: "",
- current: 1,
- size: 10,
- prodEntp:"",
- isFas:"",
- },
- consumableData: [],
- selectData: [],
- dialogLoading: false,
- Loading: false,
- cellList: [],
- isFasData: [
- { value: "0", name: "是" },
- { value: "1", name: "否" },
- ],
- };
- },
- methods: {
- getDetails() {
- this.dialog = true;
- this.getdialog();
- this.$nextTick(() => {
- this.$refs.multipleTable.clearSelection();
- this.tableData.forEach((i) => {
- this.consumableData.forEach((row) => {
- if (i.id == row.id) {
- this.$refs.multipleTable.toggleRowSelection(row, true);
- }
- });
- });
- });
- },
- // 列表数据
- getData() {
- this.Loading = true;
- getPurcOrdDrugList(this.listForm)
- .then((res) => {
- this.tableData = res.data.records;
- this.Loading = false;
- })
- .catch((err) => {
- this.Loading = false;
- });
- },
- // 重置
- reset(){
- this.$refs.listQuery.resetFields();
- this.getdialog();
- },
- // 采购明细数据
- getdialog(type) {
- if (type == "search") {
- this.listQuery.current = 1;
- }
- this.dialogLoading = true;
- getMcsPurcOrdMx(this.listQuery)
- .then((res) => {
- this.consumableData = res.data.records;
- this.consumableData.forEach((i) => {
- i.docmkDate = moment(i.docmkDate).format("YYYY-MM-DD HH:mm:ss");
- });
- this.total = res.data.total;
- this.dialogLoading = false;
- })
- .catch((err) => {
- this.dialogLoading = false;
- });
- },
- //删除
- handleDelete(row, i) {
- const index = this.tableData.findIndex(
- (item) => item.prodCode === row.prodCode
- );
- if (index !== -1) {
- let qwe = this.tableData.findIndex(function (item) {
- return item.prodCode == row.prodCode;
- });
- this.tableData.splice(i, 1);
- this.cellList.splice(i, 1);
- this.cellList[qwe]--;
- }
- row.showDeleteButton = false;
- this.shanchu3(row);
- // if(this.number[index]){
- // this.shanchu2(row,index);
- // }else{
- // this.shanchu(row);
- // }
- // this.number.splice(i,1);
- },
- // 合并列
- handleSpan({ row, column, rowIndex, columnIndex }) {
- if (
- columnIndex === 1 ||
- columnIndex === 2 ||
- columnIndex === 3 ||
- columnIndex === 4 ||
- columnIndex === 5 ||
- columnIndex === 6 ||
- columnIndex === 7 ||
- columnIndex === 8
- ) {
- // console.log("单元格数组,若下一项为0,则代表合并上一项", this.cellList);
- const rowCell = this.cellList[rowIndex];
- if (rowCell > 0) {
- const colCell = 1;
- // console.log(`动态竖向合并单元格, 第${colCell}列,竖向合并${rowCell}个单元格 `);
- return {
- rowspan: rowCell,
- colspan: colCell,
- };
- } else {
- // 清除原有的单元格,必须要加,否则就会出现单元格会被横着挤到后面了!!!
- // 本例中数据是写死的不会出现,数据若是动态后端获取的,就会出现了!!!
- return {
- rowspan: 0,
- colspan: 0,
- };
- }
- }
- },
- //弹框选择
- handleSelectionChange(e) {
- this.selectData = e;
- },
- // 出库
- handleDelivery() {
- this.tableData.forEach((item) => {
- // console.log(item, "item");
- if (item.delvCnt == "0") {
- this.$message({
- message: "本次出库数量必须大于0",
- type: "warning",
- });
- throw new Error("本次出库数量必须大于0");
- }
- if (item.prodSouc == "2" && !item.invoFileId) {
- this.$message({
- message: "请填写相应信息,并选择报关单",
- type: "warning",
- });
- throw new Error("请填写相应信息,并选择报关单");
- }
- });
- this.$refs.tabledata.validate((valid) => {
- if (valid) {
- let data = this.tableData.map((i) => {
- return i.purcOrdId;
- });
- let data2 = data.slice(1);
- let qwe = data2.some((item) => {
- if (item != data[0]) {
- return true;
- }
- });
- if (qwe == true) {
- this.$message.info("请勾选同一采购单明细");
- } else {
- this.$confirm("确认出库", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- let data = this.tableData.map((i) => {
- return {
- materialId: i.prodCode,
- memo: i.memo,
- delvCnt: i.delvCnt,
- hiCode: i.hiCode,
- delvPric: i.purcPric,
- lotNum: i.lotNum,
- manuDate: i.manuDate,
- prodExpy: i.prodExpy,
- invoFileId: i.invoFileId,
- dyntFileId: i.dyntFileId,
- noRow: i.index,
- };
- });
- let data2 = {
- delvOrdId: "",
- spdId: "",
- detlList: data,
- dyntNo: this.listForm.dyntNo,
- purcOrdId: this.tableData[0].purcOrdId,
- };
- submitMcsDelvOrd(data2)
- .then((res) => {
- this.getdialog();
- this.tableData = [];
- this.selectData = [];
- this.$message({
- message: '出库成功',
- type: 'success'
- });
- this.listForm.dyntNo = "";
- })
- .catch((err) => {});
- });
- }
- } else {
- this.$message({
- type: "warning",
- message: "请填写必填项信息",
- });
- }
- });
- },
- // 添加批次
- handleBatch(row, index) {
- let list = {
- purcOrdId: row.purcOrdId,
- prodCode: row.prodCode,
- regcertno: row.regcertno,
- delvCnt: "",
- delvCntYck: row.delvCntYck,
- docmkDate: row.docmkDate,
- docmker: row.docmker,
- essdrugType: row.essdrugType,
- prodEntp: row.prodEntp,
- materialId: row.materialId,
- id: row.id,
- prodName: row.prodName,
- hiCode: row.hiCode,
- mol: row.mol,
- matl: row.matl,
- memo: row.memo,
- mcsType: row.mcsType,
- purcPric: row.purcPric,
- purcAmt: row.purcAmt,
- purcCnt: row.purcCnt,
- prodSouc: row.prodSouc,
- spec: row.spec,
- toDelvCnt: row.toDelvCnt,
- invoFileId: "",
- lotNum: "",
- manuDate: "",
- prodExpy: "",
- dyntFileId: "",
- };
- this.tableData.splice(index + 1, 0, list);
- list.showDeleteButton = true;
- this.computeCell(this.tableData);
- console.log(this.tableData, "tableData");
- // const aa = this.tableData.findIndex((item) => item.id === row.id);
- // this.number.splice(aa+1,0,this.number[aa])
- },
- getUpload1(id, index) {
- this.tableData[index].invoFileId = id;
- if (id) {
- this.$refs.tabledata.clearValidate("invoFileId");
- } else {
- this.$refs.tabledata.validateField("invoFileId");
- }
- },
- // 筛选合并项
- computeCell(tableData) {
- this.cellList = [];
- this.count = null;
- for (let i = 0; i < tableData.length; i++) {
- if (i == 0) {
- // 先设置第一项
- this.cellList.push(1); // 初为1,若下一项和此项相同,就往cellList数组中追加0
- this.count = 0;
- console.log("索引", 0, this.count);
- } else {
- // 判断当前项与上项的设备类别是否相同,因为是合并这一列的单元格
- if (tableData[i].id == tableData[i - 1].id) {
- this.cellList[this.count] += 1; // 增加计数
- this.cellList.push(0); // 相等就往cellList数组中追加0
- console.log("索引", i, this.count);
- } else {
- this.cellList.push(1); // 不等就往cellList数组中追加1
- this.count = i; // 将索引赋值为计数
- console.log("索引", i, this.count);
- }
- }
- }
- },
- //获取出库数量和
- numAll(row) {
- let num = 0;
- this.tableData.forEach((item) => {
- if (item.prodCode == row.prodCode) {
- num += item.delvCnt;
- }
- });
- return num;
- },
- shanchu3(row) {
- this.tableData.forEach(async (item) => {
- await this.numAll(row);
- console.log(this.numAll(row), "he");
- if (item.prodCode == row.prodCode) {
- if (this.numAll(row) > item.toDelvCnt) {
- this.$message.warning("出库数量不能大于待出库数量");
- row.delvCnt = 0;
- row.price = 0;
- return;
- }
- }
- let choose = this.tableData;
- this.tableData = choose;
- });
- },
- numOrPriceChange(index, row) {
- this.$set(
- this.tableData[index],
- "price",
- getTotalAmount(row.delvCnt, row.purcPric)
- );
- this.amount = countNumPrice(this.tableData);
- },
- // 出库数量变更
- updateNum(row, index) {
- // const aa = this.tableData.findIndex((item) => item.id === row.id);
- // if(this.number[aa]){
- // this.shanchu2(row,aa);
- // }else{
- // this.shanchu(row);
- // }
- this.shanchu3(row);
- this.numOrPriceChange(index, row);
- },
- // 确认
- handleConfirm() {
- let data = this.selectData.map((i) => {
- return i.purcOrdId;
- });
- let data2 = data.slice(1);
- let qwe = data2.some((item) => {
- if (item != data[0]) {
- return true;
- }
- });
- if (qwe == true) {
- this.$message.info("请勾选同一采购单明细");
- } else {
- this.tableData = this.selectData;
- this.computeCell(this.tableData);
- this.dialog = false;
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped></style>
|