purchaseDetails.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <!-- 采购明细出库 -->
  3. <div>
  4. <div class="common-card">
  5. <el-form :model="listForm" ref="planForm" :inline="true">
  6. <el-form-item label="采购单号" prop="dyntNo">
  7. <el-input v-model="listForm.dyntNo" placeholder="请输入采购单号"></el-input>
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button type="primary" @click="getDetails('search')"
  11. >提取采购明细
  12. </el-button>
  13. </el-form-item>
  14. </el-form>
  15. </div>
  16. <div class="common-card">
  17. <el-form :model="tableData" ref="tabledata">
  18. <el-table
  19. :data="tableData"
  20. v-loading="loding"
  21. element-loading-text="加载中..."
  22. border
  23. :span-method="handleSpan"
  24. >
  25. <template slot="empty">
  26. <img src="@/assets/nopage.png" alt />
  27. <p>暂无数据</p>
  28. </template>
  29. <el-table-column fixed type="index" label="序号" width="60" />
  30. <el-table-column label="采购单号" prop="purcOrdId" />
  31. <el-table-column label="耗材编码" prop="prodCode" />
  32. <el-table-column label="医保编码" prop="hiCode" />
  33. <el-table-column label="耗材信息" width="300">
  34. <template slot-scope="scope">
  35. <mcs-info :info="scope.row"></mcs-info>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="规格" prop="spec" />
  39. <el-table-column label="型号" prop="mol" />
  40. <el-table-column label="材质" prop="matl" />
  41. <el-table-column label="单价" prop="purcPric" />
  42. <el-table-column label="批号" prop="lotNum" width="120">
  43. <template slot-scope="scope">
  44. <el-form-item
  45. label-width="0"
  46. class="item"
  47. :prop="scope.$index + '.lotNum'"
  48. :rules="[
  49. {
  50. required: true,
  51. message: '请输入',
  52. trigger: 'blur',
  53. },
  54. ]"
  55. >
  56. <el-input placeholder="请输入" v-model="scope.row.lotNum"></el-input>
  57. </el-form-item>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="生产日期" prop="manuDate" width="220">
  61. <template slot-scope="scope">
  62. <el-form-item
  63. label-width="0"
  64. class="item"
  65. :prop="scope.$index + '.manuDate'"
  66. :rules="[
  67. {
  68. required: true,
  69. message: '请选择生产日期',
  70. trigger: 'change',
  71. },
  72. ]"
  73. >
  74. <el-date-picker
  75. style="width: 100%"
  76. v-model="scope.row.manuDate"
  77. type="date"
  78. placeholder="请选择生产日期"
  79. value-format="yyyy-MM-dd"
  80. />
  81. </el-form-item>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="有效期至" width="220" prop="prodExpy">
  85. <template slot-scope="scope">
  86. <el-form-item
  87. label-width="0"
  88. class="item"
  89. :prop="scope.$index + '.prodExpy'"
  90. :rules="[
  91. {
  92. required: true,
  93. message: '请选择有效期',
  94. trigger: 'change',
  95. },
  96. ]"
  97. >
  98. <el-date-picker
  99. style="width: 100%"
  100. v-model="scope.row.prodExpy"
  101. type="date"
  102. placeholder="请选择有效期"
  103. value-format="yyyy-MM-dd"
  104. />
  105. </el-form-item>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="需求数量" prop="purcCnt" />
  109. <!-- <el-table-column label="已出库数量" prop="delvCntYck" width="90px" /> -->
  110. <el-table-column label="剩余出库量" prop="toDelvCnt" width="90px" />
  111. <el-table-column label="出库数量" prop="delvCnt" width="150">
  112. <template slot-scope="scope">
  113. <el-form-item
  114. label-width="0"
  115. class="item"
  116. :prop="scope.$index + '.delvCnt'"
  117. :rules="[
  118. {
  119. required: true,
  120. pattern: /^[0-9]\d*$/,
  121. message: '请输入正整数',
  122. trigger: 'blur',
  123. },
  124. ]"
  125. >
  126. <el-input-number
  127. v-model="scope.row.delvCnt"
  128. controls-position="right"
  129. @change="updateNum(scope.row, scope.$index)"
  130. :min="0"
  131. ></el-input-number>
  132. </el-form-item>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="报关单" prop="invoFileId" width="200">
  136. <template slot-scope="scope">
  137. <yl-upload
  138. v-if="scope.row.prodSouc == '2'"
  139. :fileId="scope.row.invoFileId"
  140. @getUpload="getUpload1"
  141. urlName="acco"
  142. :index="scope.$index"
  143. >
  144. <template v-slot:dec>只能上传pdf文件</template>
  145. </yl-upload>
  146. </template>
  147. </el-table-column>
  148. <!-- <el-table-column label="随货单" prop="dyntFileId" width="200">
  149. <template slot-scope="scope">
  150. <yl-upload
  151. :fileId="scope.row.dyntFileId"
  152. @getUpload="getUpload"
  153. urlName="acco"
  154. :index="scope.$index"
  155. >
  156. <template v-slot:dec>只能上传pdf文件</template>
  157. </yl-upload>
  158. </template>
  159. </el-table-column> -->
  160. <el-table-column label="备注" prop="memo" width="120">
  161. <template slot-scope="scope">
  162. <el-form-item label-width="0" class="item">
  163. <el-input placeholder="请输入" v-model="scope.row.memo"></el-input>
  164. </el-form-item>
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="center" fixed="right" label="操作" width="120">
  168. <template slot-scope="scope">
  169. <el-button
  170. v-if="scope.row.showDeleteButton"
  171. class="red"
  172. type="text"
  173. @click="handleDelete(scope.row, scope.$index)"
  174. >删除</el-button
  175. >
  176. <el-button v-else type="text" @click="handleBatch(scope.row, scope.$index)"
  177. >添加批次
  178. </el-button>
  179. </template>
  180. </el-table-column>
  181. </el-table>
  182. </el-form>
  183. </div>
  184. <div class="foot-button" style="margin-top: 30px">
  185. <!-- <el-button type="success" @click="handleSave">保存</el-button> -->
  186. <el-button type="primary" @click="handleDelivery">出库</el-button>
  187. </div>
  188. <el-dialog title="提取采购单" :visible.sync="dialog" width="70%">
  189. <template>
  190. <el-form :model="listQuery" ref="listQuery" :inline="true" label-width="90px">
  191. <el-form-item size="mini" label="采购单号" prop="purcOrdId" class="long">
  192. <el-input v-model="listQuery.purcOrdId" placeholder="请输入采购单号"></el-input>
  193. </el-form-item>
  194. <el-form-item size="mini" label="耗材名称" prop="prodName" class="long">
  195. <el-input
  196. v-model="listQuery.prodName"
  197. placeholder="请输入耗材名称"
  198. ></el-input>
  199. </el-form-item>
  200. <el-form-item size="mini" label="医保编码" prop="hiCode" class="long">
  201. <el-input v-model="listQuery.hiCode" placeholder="请输入医保编码"></el-input>
  202. </el-form-item>
  203. <el-form-item size="mini" label="生产企业" prop="prodEntp" class="long">
  204. <el-input v-model="listQuery.prodEntp" placeholder="请输入生产企业"></el-input>
  205. </el-form-item>
  206. <el-form-item size="mini" label="是否集采" prop="isFas" class="long">
  207. <el-select v-model="listQuery.isFas" placeholder="请选择是否集采" clearable>
  208. <el-option
  209. v-for="item in isFasData"
  210. :key="item.value"
  211. :label="item.name"
  212. :value="item.value"
  213. ></el-option>
  214. </el-select>
  215. </el-form-item>
  216. <el-form-item size="mini" label="注册证号" prop="regcertno" class="long">
  217. <el-input v-model="listQuery.regcertno" placeholder="请输入注册证号"></el-input>
  218. </el-form-item>
  219. <el-form-item>
  220. <el-button type="primary" @click="getdialog('search')">查询</el-button>
  221. <el-button @click="reset('consumable')">重置</el-button>
  222. </el-form-item>
  223. </el-form>
  224. <el-table
  225. ref="multipleTable"
  226. v-loading="dialogLoading"
  227. element-loading-text="加载中"
  228. fit
  229. stripe
  230. border
  231. :data="consumableData"
  232. border
  233. style="width: 100%"
  234. row-key="id"
  235. height="500"
  236. @selection-change="handleSelectionChange"
  237. highlight-current-row
  238. :default-sort="{ prop: 'hiCode', order: 'descending' }"
  239. >
  240. <el-table-column
  241. type="selection"
  242. :reserve-selection="true"
  243. width="55"
  244. ></el-table-column>
  245. <el-table-column label="采购单号" prop="purcOrdId"> </el-table-column>
  246. <el-table-column label="耗材编码" prop="prodCode" />
  247. <el-table-column label="医保编码" prop="hiCode" />
  248. <el-table-column label="耗材信息" width="300">
  249. <template slot-scope="scope">
  250. <mcs-info :info="scope.row"></mcs-info>
  251. </template>
  252. </el-table-column>
  253. <el-table-column label="规格" prop="spec" />
  254. <el-table-column label="型号" prop="mol" />
  255. <el-table-column label="材质" prop="matl" />
  256. <el-table-column label="是否集采" prop="isFas">
  257. <template #default="{ row }">
  258. <span v-if="row.isFas == '1'">否</span>
  259. <span v-if="row.isFas == '0'">是</span>
  260. </template>
  261. </el-table-column>
  262. <el-table-column label="计价单位" prop="prcUnt" />
  263. <el-table-column label="采购单位" prop="purcUnt" />
  264. <el-table-column label="包装内数量" prop="convrat" />
  265. <el-table-column label="单价" prop="purcPric" />
  266. <el-table-column label="需求数量" prop="purcCnt" />
  267. <!-- <el-table-column label="已出库数量" prop="delvCntYck" width="90px" /> -->
  268. <el-table-column label="剩余出库量" prop="toDelvCnt" width="90px" />
  269. </el-table>
  270. <div slot="footer" class="dialog-footer">
  271. <el-button type="primary" @click="handleConfirm">确认</el-button>
  272. </div>
  273. <!--分页-->
  274. <yl-pagination
  275. v-show="total > 0"
  276. :total="total"
  277. :page.sync="listQuery.current"
  278. :limit.sync="listQuery.size"
  279. @pagination="getdialog"
  280. />
  281. </template>
  282. </el-dialog>
  283. </div>
  284. </template>
  285. <script>
  286. import mcsInfo from "@/views/components/mcs-info.vue";
  287. import ylUpload from "@/components/yl-upload";
  288. import { countNumPrice, getTotalAmount } from "@/utils/utils";
  289. import rules from "@/utils/rules";
  290. import { getMcsPurcOrdMx, submitMcsDelvOrd } from "@/api/orderManage-sup/index";
  291. export default {
  292. components: {
  293. mcsInfo,
  294. ylUpload,
  295. },
  296. data() {
  297. return {
  298. rules,
  299. listForm: {
  300. dyntNo: "",
  301. current: 1,
  302. size: 10,
  303. },
  304. planForm: {},
  305. // 表格数据
  306. loding: false,
  307. tableData: [],
  308. // 弹框表格数据
  309. dialog: false,
  310. listQuery: {
  311. hiCode: "",
  312. prodName: "",
  313. purcOrdId: "",
  314. current: 1,
  315. size: 10,
  316. prodEntp:"",
  317. isFas:"",
  318. },
  319. consumableData: [],
  320. selectData: [],
  321. dialogLoading: false,
  322. Loading: false,
  323. cellList: [],
  324. isFasData: [
  325. { value: "0", name: "是" },
  326. { value: "1", name: "否" },
  327. ],
  328. };
  329. },
  330. methods: {
  331. getDetails() {
  332. this.dialog = true;
  333. this.getdialog();
  334. this.$nextTick(() => {
  335. this.$refs.multipleTable.clearSelection();
  336. this.tableData.forEach((i) => {
  337. this.consumableData.forEach((row) => {
  338. if (i.id == row.id) {
  339. this.$refs.multipleTable.toggleRowSelection(row, true);
  340. }
  341. });
  342. });
  343. });
  344. },
  345. // 列表数据
  346. getData() {
  347. this.Loading = true;
  348. getPurcOrdDrugList(this.listForm)
  349. .then((res) => {
  350. this.tableData = res.data.records;
  351. this.Loading = false;
  352. })
  353. .catch((err) => {
  354. this.Loading = false;
  355. });
  356. },
  357. // 重置
  358. reset(){
  359. this.$refs.listQuery.resetFields();
  360. this.getdialog();
  361. },
  362. // 采购明细数据
  363. getdialog(type) {
  364. if (type == "search") {
  365. this.listQuery.current = 1;
  366. }
  367. this.dialogLoading = true;
  368. getMcsPurcOrdMx(this.listQuery)
  369. .then((res) => {
  370. this.consumableData = res.data.records;
  371. this.consumableData.forEach((i) => {
  372. i.docmkDate = moment(i.docmkDate).format("YYYY-MM-DD HH:mm:ss");
  373. });
  374. this.total = res.data.total;
  375. this.dialogLoading = false;
  376. })
  377. .catch((err) => {
  378. this.dialogLoading = false;
  379. });
  380. },
  381. //删除
  382. handleDelete(row, i) {
  383. const index = this.tableData.findIndex(
  384. (item) => item.prodCode === row.prodCode
  385. );
  386. if (index !== -1) {
  387. let qwe = this.tableData.findIndex(function (item) {
  388. return item.prodCode == row.prodCode;
  389. });
  390. this.tableData.splice(i, 1);
  391. this.cellList.splice(i, 1);
  392. this.cellList[qwe]--;
  393. }
  394. row.showDeleteButton = false;
  395. this.shanchu3(row);
  396. // if(this.number[index]){
  397. // this.shanchu2(row,index);
  398. // }else{
  399. // this.shanchu(row);
  400. // }
  401. // this.number.splice(i,1);
  402. },
  403. // 合并列
  404. handleSpan({ row, column, rowIndex, columnIndex }) {
  405. if (
  406. columnIndex === 1 ||
  407. columnIndex === 2 ||
  408. columnIndex === 3 ||
  409. columnIndex === 4 ||
  410. columnIndex === 5 ||
  411. columnIndex === 6 ||
  412. columnIndex === 7 ||
  413. columnIndex === 8
  414. ) {
  415. // console.log("单元格数组,若下一项为0,则代表合并上一项", this.cellList);
  416. const rowCell = this.cellList[rowIndex];
  417. if (rowCell > 0) {
  418. const colCell = 1;
  419. // console.log(`动态竖向合并单元格, 第${colCell}列,竖向合并${rowCell}个单元格 `);
  420. return {
  421. rowspan: rowCell,
  422. colspan: colCell,
  423. };
  424. } else {
  425. // 清除原有的单元格,必须要加,否则就会出现单元格会被横着挤到后面了!!!
  426. // 本例中数据是写死的不会出现,数据若是动态后端获取的,就会出现了!!!
  427. return {
  428. rowspan: 0,
  429. colspan: 0,
  430. };
  431. }
  432. }
  433. },
  434. //弹框选择
  435. handleSelectionChange(e) {
  436. this.selectData = e;
  437. },
  438. // 出库
  439. handleDelivery() {
  440. this.tableData.forEach((item) => {
  441. // console.log(item, "item");
  442. if (item.delvCnt == "0") {
  443. this.$message({
  444. message: "本次出库数量必须大于0",
  445. type: "warning",
  446. });
  447. throw new Error("本次出库数量必须大于0");
  448. }
  449. if (item.prodSouc == "2" && !item.invoFileId) {
  450. this.$message({
  451. message: "请填写相应信息,并选择报关单",
  452. type: "warning",
  453. });
  454. throw new Error("请填写相应信息,并选择报关单");
  455. }
  456. });
  457. this.$refs.tabledata.validate((valid) => {
  458. if (valid) {
  459. let data = this.tableData.map((i) => {
  460. return i.purcOrdId;
  461. });
  462. let data2 = data.slice(1);
  463. let qwe = data2.some((item) => {
  464. if (item != data[0]) {
  465. return true;
  466. }
  467. });
  468. if (qwe == true) {
  469. this.$message.info("请勾选同一采购单明细");
  470. } else {
  471. this.$confirm("确认出库", "提示", {
  472. confirmButtonText: "确定",
  473. cancelButtonText: "取消",
  474. type: "warning",
  475. }).then(() => {
  476. let data = this.tableData.map((i) => {
  477. return {
  478. materialId: i.prodCode,
  479. memo: i.memo,
  480. delvCnt: i.delvCnt,
  481. hiCode: i.hiCode,
  482. delvPric: i.purcPric,
  483. lotNum: i.lotNum,
  484. manuDate: i.manuDate,
  485. prodExpy: i.prodExpy,
  486. invoFileId: i.invoFileId,
  487. dyntFileId: i.dyntFileId,
  488. noRow: i.index,
  489. };
  490. });
  491. let data2 = {
  492. delvOrdId: "",
  493. spdId: "",
  494. detlList: data,
  495. dyntNo: this.listForm.dyntNo,
  496. purcOrdId: this.tableData[0].purcOrdId,
  497. };
  498. submitMcsDelvOrd(data2)
  499. .then((res) => {
  500. this.getdialog();
  501. this.tableData = [];
  502. this.selectData = [];
  503. this.$message({
  504. message: '出库成功',
  505. type: 'success'
  506. });
  507. this.listForm.dyntNo = "";
  508. })
  509. .catch((err) => {});
  510. });
  511. }
  512. } else {
  513. this.$message({
  514. type: "warning",
  515. message: "请填写必填项信息",
  516. });
  517. }
  518. });
  519. },
  520. // 添加批次
  521. handleBatch(row, index) {
  522. let list = {
  523. purcOrdId: row.purcOrdId,
  524. prodCode: row.prodCode,
  525. regcertno: row.regcertno,
  526. delvCnt: "",
  527. delvCntYck: row.delvCntYck,
  528. docmkDate: row.docmkDate,
  529. docmker: row.docmker,
  530. essdrugType: row.essdrugType,
  531. prodEntp: row.prodEntp,
  532. materialId: row.materialId,
  533. id: row.id,
  534. prodName: row.prodName,
  535. hiCode: row.hiCode,
  536. mol: row.mol,
  537. matl: row.matl,
  538. memo: row.memo,
  539. mcsType: row.mcsType,
  540. purcPric: row.purcPric,
  541. purcAmt: row.purcAmt,
  542. purcCnt: row.purcCnt,
  543. prodSouc: row.prodSouc,
  544. spec: row.spec,
  545. toDelvCnt: row.toDelvCnt,
  546. invoFileId: "",
  547. lotNum: "",
  548. manuDate: "",
  549. prodExpy: "",
  550. dyntFileId: "",
  551. };
  552. this.tableData.splice(index + 1, 0, list);
  553. list.showDeleteButton = true;
  554. this.computeCell(this.tableData);
  555. console.log(this.tableData, "tableData");
  556. // const aa = this.tableData.findIndex((item) => item.id === row.id);
  557. // this.number.splice(aa+1,0,this.number[aa])
  558. },
  559. getUpload1(id, index) {
  560. this.tableData[index].invoFileId = id;
  561. if (id) {
  562. this.$refs.tabledata.clearValidate("invoFileId");
  563. } else {
  564. this.$refs.tabledata.validateField("invoFileId");
  565. }
  566. },
  567. // 筛选合并项
  568. computeCell(tableData) {
  569. this.cellList = [];
  570. this.count = null;
  571. for (let i = 0; i < tableData.length; i++) {
  572. if (i == 0) {
  573. // 先设置第一项
  574. this.cellList.push(1); // 初为1,若下一项和此项相同,就往cellList数组中追加0
  575. this.count = 0;
  576. console.log("索引", 0, this.count);
  577. } else {
  578. // 判断当前项与上项的设备类别是否相同,因为是合并这一列的单元格
  579. if (tableData[i].id == tableData[i - 1].id) {
  580. this.cellList[this.count] += 1; // 增加计数
  581. this.cellList.push(0); // 相等就往cellList数组中追加0
  582. console.log("索引", i, this.count);
  583. } else {
  584. this.cellList.push(1); // 不等就往cellList数组中追加1
  585. this.count = i; // 将索引赋值为计数
  586. console.log("索引", i, this.count);
  587. }
  588. }
  589. }
  590. },
  591. //获取出库数量和
  592. numAll(row) {
  593. let num = 0;
  594. this.tableData.forEach((item) => {
  595. if (item.prodCode == row.prodCode) {
  596. num += item.delvCnt;
  597. }
  598. });
  599. return num;
  600. },
  601. shanchu3(row) {
  602. this.tableData.forEach(async (item) => {
  603. await this.numAll(row);
  604. console.log(this.numAll(row), "he");
  605. if (item.prodCode == row.prodCode) {
  606. if (this.numAll(row) > item.toDelvCnt) {
  607. this.$message.warning("出库数量不能大于待出库数量");
  608. row.delvCnt = 0;
  609. row.price = 0;
  610. return;
  611. }
  612. }
  613. let choose = this.tableData;
  614. this.tableData = choose;
  615. });
  616. },
  617. numOrPriceChange(index, row) {
  618. this.$set(
  619. this.tableData[index],
  620. "price",
  621. getTotalAmount(row.delvCnt, row.purcPric)
  622. );
  623. this.amount = countNumPrice(this.tableData);
  624. },
  625. // 出库数量变更
  626. updateNum(row, index) {
  627. // const aa = this.tableData.findIndex((item) => item.id === row.id);
  628. // if(this.number[aa]){
  629. // this.shanchu2(row,aa);
  630. // }else{
  631. // this.shanchu(row);
  632. // }
  633. this.shanchu3(row);
  634. this.numOrPriceChange(index, row);
  635. },
  636. // 确认
  637. handleConfirm() {
  638. let data = this.selectData.map((i) => {
  639. return i.purcOrdId;
  640. });
  641. let data2 = data.slice(1);
  642. let qwe = data2.some((item) => {
  643. if (item != data[0]) {
  644. return true;
  645. }
  646. });
  647. if (qwe == true) {
  648. this.$message.info("请勾选同一采购单明细");
  649. } else {
  650. this.tableData = this.selectData;
  651. this.computeCell(this.tableData);
  652. this.dialog = false;
  653. }
  654. },
  655. },
  656. };
  657. </script>
  658. <style lang="scss" scoped></style>