editPurchaseOrder.vue 38KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs="crumbs"></bread-crumb>
  5. </div>
  6. <div class="app-container" v-loading="loading">
  7. <div
  8. style="
  9. justify-content: space-between;
  10. margin: 0px 0 12px 0;
  11. display: flex;
  12. align-items: center;
  13. "
  14. >
  15. <div>
  16. <span style="color: red">*</span><span>供应商:</span>
  17. <el-select
  18. v-model="supplier_name"
  19. style="width: 140px; margin-right: 10px"
  20. placeholder="请选择"
  21. @change="changeTypeName"
  22. :disabled="disabled"
  23. >
  24. <el-option
  25. v-for="item in supplyList"
  26. :key="item.id"
  27. :label="item.supplier_name"
  28. :value="item.id"
  29. >
  30. </el-option>
  31. </el-select>
  32. <span>单据日期:</span>
  33. <el-date-picker
  34. size="small"
  35. v-model="start_time"
  36. prefix-icon="el-icon-date"
  37. :editable="false"
  38. style="width: 196px"
  39. type="date"
  40. placeholder="选择日期时间"
  41. align="right"
  42. format="yyyy-MM-dd"
  43. value-format="yyyy-MM-dd"
  44. :disabled="disabled"
  45. ></el-date-picker>
  46. <span>交货日期:</span>
  47. <el-date-picker
  48. size="small"
  49. v-model="end_time"
  50. prefix-icon="el-icon-date"
  51. :editable="false"
  52. style="width: 196px"
  53. type="date"
  54. placeholder="选择日期时间"
  55. align="right"
  56. format="yyyy-MM-dd"
  57. value-format="yyyy-MM-dd"
  58. @change="endTimeChange"
  59. :disabled="disabled"
  60. ></el-date-picker>
  61. <span>单据编码:{{ number }}</span>
  62. </div>
  63. <div style="display: flex;">
  64. <el-button size="small" type="primary" @click="toAdd" v-show="showOne"
  65. >生成采购单</el-button
  66. >
  67. <el-button size="small" type="primary" @click="updatePurchaseOrder"
  68. >保存</el-button
  69. >
  70. <el-button size="small" type="primary" @click="toPrint"
  71. >打印</el-button
  72. >
  73. <el-button
  74. size="small"
  75. type="primary"
  76. v-if="is_check == 2"
  77. @click="checkPurchaseOrder"
  78. v-show="showTwo"
  79. >审核</el-button
  80. >
  81. <el-button
  82. size="small"
  83. type="primary"
  84. v-if="is_check == 1"
  85. @click="checkReturnOrder"
  86. v-show="showThree"
  87. >反审核</el-button
  88. >
  89. </div>
  90. </div>
  91. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  92. <el-table
  93. :row-style="{ color: '#303133' }"
  94. :header-cell-style="{
  95. backgroundColor: 'rgb(245, 247, 250)',
  96. color: '#606266',
  97. }"
  98. :data="recordInfo.tableList"
  99. :class="signAndWeighBoxPatients"
  100. border
  101. style="width: 100%"
  102. max-height="450"
  103. >
  104. <el-table-column align="center" width="200px">
  105. <template slot="header" slot-scope="scope">
  106. <span>商品<span style="color: red">*</span></span>
  107. </template>
  108. <template slot-scope="scope">
  109. <el-form-item
  110. :prop="'tableList.' + scope.$index + '.name'"
  111. :rules="tableRules.name"
  112. >
  113. <el-select
  114. v-model="scope.row.name"
  115. style="width: 160px"
  116. filterable
  117. placeholder="请选择"
  118. @change="changeName"
  119. @input="changeGoodName(scope.$index)"
  120. :disabled="disabled"
  121. >
  122. <el-option
  123. v-for="(item, index) in tabList"
  124. :key="index"
  125. :label="item.supply_name"
  126. :value="item"
  127. >
  128. </el-option>
  129. </el-select>
  130. </el-form-item>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" width="150px">
  134. <template slot="header" slot-scope="scope">
  135. <span>商品类别</span>
  136. </template>
  137. <template slot-scope="scope">
  138. <el-input
  139. v-model="scope.row.supply_type"
  140. style="width: 120px"
  141. :disabled="true"
  142. ></el-input>
  143. <div style="visibility: hidden">/</div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="规格&单位" align="center" width="200px">
  147. <template slot-scope="scope">
  148. <el-input
  149. v-model="scope.row.supply_specification_name"
  150. style="width: 150px"
  151. :disabled="true"
  152. ></el-input>
  153. <div style="visibility: hidden">/</div>
  154. </template>
  155. </el-table-column>
  156. <el-table-column label="单位" align="center" width="120px">
  157. <template slot="header" slot-scope="scope">
  158. <span>单位<span style="color: red">*</span></span>
  159. </template>
  160. <template slot-scope="scope">
  161. <el-form-item
  162. :prop="'tableList.' + scope.$index + '.supply_unit'"
  163. :rules="tableRules.supply_unit"
  164. >
  165. <el-select
  166. v-model="scope.row.supply_unit"
  167. style="width: 100px"
  168. filterable
  169. placeholder="请选择"
  170. :disabled="disabled"
  171. >
  172. <el-option
  173. v-for="(item, index) in scope.row.unitList"
  174. :key="index"
  175. :label="item.name"
  176. :value="item.name"
  177. >
  178. </el-option>
  179. </el-select>
  180. </el-form-item>
  181. </template>
  182. </el-table-column>
  183. <el-table-column label="可用库存" align="center" width="130px">
  184. <template slot-scope="scope">
  185. <el-input
  186. v-model="scope.row.supply_total"
  187. style="width: 100px"
  188. :disabled="true"
  189. ></el-input>
  190. <div style="visibility: hidden">/</div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="数量" align="center" width="180px">
  194. <template slot="header" slot-scope="scope">
  195. <span>数量<span style="color: red">*</span></span>
  196. </template>
  197. <template slot-scope="scope">
  198. <el-form-item
  199. :prop="'tableList.' + scope.$index + '.supply_count'"
  200. :rules="tableRules.supply_count"
  201. >
  202. <el-input
  203. v-model="scope.row.supply_count"
  204. style="width: 140px"
  205. :disabled="disabled"
  206. placeholder="请输入数量"
  207. ></el-input>
  208. </el-form-item>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="采购单价" align="center" width="120px">
  212. <template slot-scope="scope">
  213. <el-input
  214. v-model="scope.row.supply_price"
  215. style="width: 80px"
  216. :disabled="disabled"
  217. placeholder="请输入采购单价"
  218. ></el-input>
  219. <div style="visibility: hidden">/</div>
  220. </template>
  221. </el-table-column>
  222. <el-table-column label="采购金额" align="center" width="120px">
  223. <template slot-scope="scope">
  224. {{ calculate(scope.row.supply_count * scope.row.supply_price) }}
  225. <div style="visibility: hidden">/</div>
  226. </template>
  227. </el-table-column>
  228. <el-table-column label="生产厂家" align="center" width="200px">
  229. <template slot-scope="scope">
  230. <el-select
  231. size="small"
  232. v-model="scope.row.supply_manufacturer"
  233. filterable
  234. :disabled="true"
  235. >
  236. <el-option
  237. v-for="(option, index) in manufactuerList"
  238. :key="index"
  239. :label="option.manufacturer_name"
  240. :value="option.id"
  241. >
  242. </el-option>
  243. </el-select>
  244. <div style="visibility: hidden">/</div>
  245. </template>
  246. </el-table-column>
  247. <el-table-column label="批准文号" align="center" width="200px">
  248. <template slot-scope="scope">
  249. <el-input
  250. v-model="scope.row.supply_license_number"
  251. style="width: 160px"
  252. :disabled="true"
  253. ></el-input>
  254. <div style="visibility: hidden">/</div>
  255. </template>
  256. </el-table-column>
  257. <el-table-column label="备注" align="center" width="200px">
  258. <template slot-scope="scope">
  259. <el-input
  260. v-model="scope.row.supply_remake"
  261. style="width: 160px"
  262. :disabled="disabled"
  263. placeholder="请输入备注"
  264. ></el-input>
  265. <div style="visibility: hidden">/</div>
  266. </template>
  267. </el-table-column>
  268. <el-table-column
  269. label="操作"
  270. align="center"
  271. width="150px"
  272. fixed="right"
  273. >
  274. <template slot-scope="scope">
  275. <el-tooltip
  276. class="item"
  277. effect="dark"
  278. content="新增"
  279. placement="top"
  280. >
  281. <el-button
  282. size="mini"
  283. type="primary"
  284. icon="el-icon-circle-plus-outline"
  285. @click="handleEdit(scope.$index, scope.row)"
  286. >
  287. </el-button>
  288. </el-tooltip>
  289. <el-tooltip
  290. class="item"
  291. effect="dark"
  292. content="删除"
  293. placement="top"
  294. >
  295. <el-button
  296. size="mini"
  297. type="danger"
  298. icon="el-icon-delete"
  299. @click="handleDelete(scope.$index, scope.row)"
  300. >
  301. </el-button>
  302. </el-tooltip>
  303. </template>
  304. </el-table-column>
  305. </el-table>
  306. <div style="margin-top: 10px">
  307. <el-input
  308. type="textarea"
  309. :rows="2"
  310. placeholder="备注信息"
  311. v-model="return_remark"
  312. >
  313. </el-input>
  314. </div>
  315. <!-- 审核水印 -->
  316. <img
  317. src="@/assets/purchase/Reviewed.png"
  318. alt="正在加载..."
  319. class="reviewImg"
  320. v-show="Reviewed == true"
  321. />
  322. </el-form>
  323. <div style="margin-top: 10px">合计:{{ getAllPrice() }} 元</div>
  324. <div style="margin-top: 10px">
  325. <span
  326. >优惠率:<el-input
  327. style="width: 150px"
  328. v-model="rate_of_concession"
  329. @input="addressChange"
  330. :disabled="disabled"
  331. placeholder="请输入优惠率"
  332. ></el-input
  333. >%</span
  334. >
  335. <span
  336. >优惠金额:<el-input
  337. style="width: 150px"
  338. v-model="discount_amount"
  339. :disabled="disabled"
  340. placeholder="请输入优惠金额"
  341. ></el-input
  342. ></span>
  343. </div>
  344. </div>
  345. <!-- <el-dialog
  346. title="系统提示"
  347. :visible.sync="dialogVisible"
  348. width="30%">
  349. <span>
  350. 采购订单{{number}}已有以下关联数据,不能反审核
  351. <div v-for="(item,index) in orderList" :key="index">
  352. <li>采购单{{item.good_number}}</li> <a @click="toClick(item.id)">点击查看</a>
  353. </div>
  354. </span>
  355. <span slot="footer" class="dialog-footer">
  356. <el-button @click="dialogVisible = false">取 消</el-button>
  357. </span>
  358. </el-dialog> -->
  359. <popup ref="Popup" :content="content" :content_1="content_1" :content_2="content_2" :number="number" :orderList ="orderList" :type="type"></popup>
  360. </div>
  361. </template>
  362. <script>
  363. import popup from "./Popup"
  364. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  365. import { uParseTime } from "@/utils/tools";
  366. import {
  367. getInitOrder,
  368. updatePurchaseOrder,
  369. checkPurchaseOrder,
  370. getPurchaseOrderDetail,
  371. getAllOrderCountList,
  372. getGoodOrderList,
  373. getReturnOrder,
  374. deletePurchaseOrder
  375. } from "@/api/supply";
  376. export default {
  377. name: "addPurchaseOrder",
  378. components: {
  379. BreadCrumb,
  380. popup
  381. },
  382. data() {
  383. return {
  384. content_2:"采购单",
  385. content:"采购订单",
  386. content_1:"已有以下关联数据,不能反审核",
  387. type:1,
  388. Reviewed: false,
  389. crumbs: [
  390. { path: false, name: "采购订单" },
  391. { path: "/supply/query", name: "编辑采购订单" },
  392. ],
  393. showTwo: true,
  394. showOne: false,
  395. recordInfo: {
  396. tableList: [],
  397. },
  398. keywords: "",
  399. total: 0,
  400. multipleSelection: [],
  401. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  402. start_time: "",
  403. end_time: "",
  404. page: 1,
  405. limit: 10,
  406. goodType: [],
  407. goodInfo: [],
  408. org_id: 0,
  409. types: [],
  410. tyep_name: "",
  411. form: {
  412. manufacturer_id: "",
  413. },
  414. tabList: [],
  415. manufactuerList: [],
  416. currentIndex: 0,
  417. goodTypeList: [],
  418. drugTypeList: [],
  419. supplier_name: "",
  420. supplyList: [],
  421. rate_of_concession: "",
  422. discount_amount: "",
  423. tableRules: {
  424. name: [{ required: true, message: "商品不能为空", trigger: "blur" }],
  425. supply_count: [
  426. { required: true, message: "数量不能为空", trigger: "blur" },
  427. ],
  428. },
  429. warehousing_id: 0,
  430. number: "",
  431. loading: false,
  432. drugList: [],
  433. goodList: [],
  434. id: 0,
  435. disabled: false,
  436. is_check: 0,
  437. dialogVisible: false,
  438. total_price: 0,
  439. showOne: true,
  440. showTwo: true,
  441. showThree: false,
  442. orderList: [],
  443. return_remark: "",
  444. };
  445. },
  446. methods: {
  447. getInitOrder() {
  448. getInitOrder().then((response) => {
  449. if (response.data.state == 1) {
  450. var drugList = response.data.data.drugList;
  451. this.manufactuerList = response.data.data.manufactuerList;
  452. this.goodTypeList = response.data.data.goodTypeList;
  453. this.drugTypeList = response.data.data.drugTypeList;
  454. this.supplyList = response.data.data.supplyList;
  455. for (let i = 0; i < drugList.length; i++) {
  456. for (let z = 0; z < drugList[i].drug_warehouse_info.length; z++) {
  457. if (
  458. drugList[i].max_unit ==
  459. drugList[i].drug_warehouse_info[z].max_unit
  460. ) {
  461. drugList[i].drug_warehouse_info[z].stock_max_number =
  462. drugList[i].drug_warehouse_info[z].stock_max_number *
  463. drugList[i].min_number;
  464. }
  465. }
  466. for (let j = 0; j < this.manufactuerList.length; j++) {
  467. if (drugList[i].manufacturer == this.manufactuerList[j].id) {
  468. drugList[i].manufacturer =
  469. this.manufactuerList[j].manufacturer_name;
  470. }
  471. }
  472. for (let y = 0; y < this.drugTypeList.length; y++) {
  473. if (drugList[i].drug_type == this.drugTypeList[y].value) {
  474. drugList[i].drug_type = this.drugTypeList[y].name;
  475. }
  476. }
  477. drugList[i].supply_name =
  478. drugList[i].drug_name +
  479. " " +
  480. drugList[i].dose +
  481. drugList[i].dose_unit +
  482. "*" +
  483. drugList[i].min_number +
  484. drugList[i].min_unit +
  485. "/" +
  486. drugList[i].max_unit +
  487. " " +
  488. drugList[i].manufacturer;
  489. drugList[i].supply_type = drugList[i].drug_type;
  490. drugList[i].supply_specification_name =
  491. drugList[i].dose +
  492. drugList[i].dose_unit +
  493. "*" +
  494. drugList[i].min_number +
  495. drugList[i].min_unit +
  496. "/" +
  497. drugList[i].max_unit;
  498. drugList[i].supply_total = this.getWarehoseInfo(
  499. drugList[i].drug_warehouse_info,
  500. drugList[i].max_unit,
  501. drugList[i].min_unit,
  502. drugList[i].min_number
  503. );
  504. drugList[i].supply_count = "";
  505. drugList[i].supply_total_price = "";
  506. drugList[i].supply_manufacturer = drugList[i].manufacturer;
  507. drugList[i].supply_license_number = drugList[i].number;
  508. drugList[i].supply_remake = "";
  509. drugList[i].type = 1;
  510. drugList[i].supply_price = drugList[i].last_price;
  511. drugList[i].name = drugList[i].drug_name;
  512. if (drugList[i].max_unit != drugList[i].min_unit) {
  513. drugList[i].unitList = [
  514. { id: 1, name: "" },
  515. { id: 2, name: "" },
  516. ];
  517. }
  518. if (drugList[i].max_unit == drugList[i].min_unit) {
  519. drugList[i].unitList = [{ id: 1, name: "" }];
  520. }
  521. drugList[i].supply_unit = drugList[i].max_unit;
  522. for (let j = 0; j < drugList[i].unitList.length; j++) {
  523. if (drugList[i].max_unit != drugList[i].min_unit) {
  524. drugList[i].unitList[0].name = drugList[i].max_unit;
  525. drugList[i].unitList[1].name = drugList[i].min_unit;
  526. }
  527. if (drugList[i].max_unit == drugList[i].min_unit) {
  528. drugList[i].unitList[0].name = drugList[i].max_unit;
  529. }
  530. }
  531. this.tabList.push(drugList[i]);
  532. }
  533. this.drugList = drugList;
  534. var goodList = response.data.data.goodList;
  535. for (let i = 0; i < goodList.length; i++) {
  536. for (let j = 0; j < this.manufactuerList.length; j++) {
  537. if (goodList[i].manufacturer == this.manufactuerList[j].id) {
  538. goodList[i].manufacturer =
  539. this.manufactuerList[j].manufacturer_name;
  540. }
  541. }
  542. for (let y = 0; y < this.goodTypeList.length; y++) {
  543. if (goodList[i].good_type_id == this.goodTypeList[y].id) {
  544. goodList[i].good_type_id = this.goodTypeList[y].type_name;
  545. }
  546. }
  547. goodList[i].supply_name =goodList[i].good_name +" " +goodList[i].specification_name +" " + goodList[i].manufacturer;
  548. goodList[i].supply_type = goodList[i].good_type_id;
  549. goodList[i].supply_specification_name =goodList[i].specification_name;
  550. goodList[i].supply_price = goodList[i].buy_price;
  551. goodList[i].supply_total = this.getTotalStockCount(goodList[i].good_warehouse_info);
  552. goodList[i].supply_count = "";
  553. goodList[i].supply_total_price = "";
  554. goodList[i].supply_manufacturer = goodList[i].manufacturer;
  555. goodList[i].supply_license_number = goodList[i].number
  556. goodList[i].supply_remake = "";
  557. goodList[i].type = 2;
  558. goodList[i].name = goodList[i].good_name;
  559. goodList[i].unitList = [{ id: 1, name: "" }];
  560. goodList[i].supply_unit = goodList[i].packing_unit;
  561. for (let j = 0; j < goodList[i].unitList.length; j++) {
  562. goodList[i].unitList[0].name = goodList[i].packing_unit;
  563. }
  564. this.tabList.push(goodList[i]);
  565. }
  566. this.goodList = goodList;
  567. }
  568. });
  569. },
  570. changeGoodName(val) {
  571. this.currentIndex = val;
  572. },
  573. changeName(val) {
  574. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  575. if (this.currentIndex == i) {
  576. this.recordInfo.tableList[i].project_id = val.id;
  577. this.recordInfo.tableList[i].type = val.type;
  578. this.recordInfo.tableList[i].name = val.name;
  579. this.recordInfo.tableList[i].supply_name = val.supply_name;
  580. this.recordInfo.tableList[i].supply_type = val.supply_type;
  581. this.recordInfo.tableList[i].supply_specification_name =val.supply_specification_name;
  582. this.recordInfo.tableList[i].supply_total = val.supply_total;
  583. if (val.supply_count == NaN) {
  584. this.recordInfo.tableList[i].supply_count = "";
  585. } else {
  586. this.recordInfo.tableList[i].supply_count = val.supply_count
  587. ? val.supply_count
  588. : "";
  589. }
  590. this.recordInfo.tableList[i].supply_price = val.supply_price? val.supply_price: "";
  591. this.recordInfo.tableList[i].supply_total_price =val.supply_total_price ? val.supply_total_price : "";
  592. this.recordInfo.tableList[i].supply_manufacturer =val.supply_manufacturer;
  593. this.recordInfo.tableList[i].supply_license_number =val.supply_license_number;
  594. this.recordInfo.tableList[i].supply_remake = val.supply_remake;
  595. this.recordInfo.tableList[i].is_total = val.is_total;
  596. this.recordInfo.tableList[i].supply_unit = val.supply_unit;
  597. this.recordInfo.tableList[i].unitList = val.unitList;
  598. }
  599. }
  600. },
  601. handleEdit() {
  602. if (this.is_check == 1) {
  603. this.$message.error("已审核的不能新增!");
  604. return false;
  605. }
  606. const tempObj = {};
  607. tempObj["id"] = 0;
  608. tempObj["name"] = "";
  609. tempObj["supply_name"] = "";
  610. tempObj["supply_type"] = "";
  611. tempObj["supply_specification_name"] = "";
  612. tempObj["supply_total"] = "";
  613. tempObj["supply_count"] = "";
  614. tempObj["supply_price"] = "";
  615. tempObj["supply_total_price"] = "";
  616. tempObj["supply_manufacturer"] = "";
  617. tempObj["supply_license_number"] = "";
  618. tempObj["supply_remake"] = "";
  619. tempObj["type"] = 0;
  620. tempObj["is_total"] = 1;
  621. tempObj["project_id"] = 0;
  622. tempObj["supply_unit"] = "";
  623. tempObj["manufacturer_id"] = "";
  624. this.recordInfo.tableList.push(tempObj);
  625. },
  626. handleDelete: function (index, row) {
  627. if(this.is_check == 1){
  628. this.$message.error("已审核单据,不能删除!")
  629. return false
  630. }
  631. if(row.id == 0){
  632. if (this.recordInfo.tableList.length <= 1) {
  633. this.$message.error("只有一条记录的时候无法删除");
  634. return;
  635. } else {
  636. this.recordInfo.tableList.splice(index, 1);
  637. }
  638. }else{
  639. const params = {
  640. id: row.id
  641. }
  642. this.$confirm('确认删除吗?', {
  643. confirmButtonText: '确定',
  644. cancelButtonText: '取消',
  645. type: 'warning'
  646. }).then(() => {
  647. deletePurchaseOrder(params).then(response => {
  648. if (response.data.state == 0) {
  649. this.$message.error(response.data.msg)
  650. return false
  651. } else {
  652. this.$message.success('删除成功')
  653. this.recordInfo.tableList.splice(index, 1)
  654. }
  655. })
  656. }).catch(() => {
  657. })
  658. }
  659. },
  660. changeTypeName() {},
  661. startTimeChange() {},
  662. endTimeChange() {},
  663. search() {},
  664. getWarehoseInfo(arr, max_unit, min_unit, min_number) {
  665. var total = 0;
  666. var max_str = "";
  667. var min_str = "";
  668. if (arr.length > 0) {
  669. for (let i = 0; i < arr.length; i++) {
  670. total += parseInt(arr[i].stock_max_number + arr[i].stock_min_number);
  671. }
  672. }
  673. if (total < min_number) {
  674. min_str = total + min_unit;
  675. }
  676. if (total == 0) {
  677. min_str = "";
  678. max_str = "";
  679. }
  680. if (total >= min_number) {
  681. if (parseInt(total / min_number) != 0) {
  682. max_str = parseInt(total / min_number) + max_unit;
  683. }
  684. if (total % min_number != 0) {
  685. min_str = (total % min_number) + min_unit;
  686. }
  687. }
  688. return max_str + min_str;
  689. },
  690. getTotalStockCount(arr) {
  691. var total_count = 0;
  692. for (let i = 0; i < arr.length; i++) {
  693. total_count += arr[i].stock_count;
  694. }
  695. return total_count;
  696. },
  697. calculate: function (val) {
  698. if (isNaN(val)) {
  699. return "";
  700. }
  701. if (val == 0) {
  702. return "";
  703. }
  704. return Math.round(parseFloat(val) * 100) / 100;
  705. },
  706. getTimes(time) {
  707. if (time === "") {
  708. return "";
  709. }
  710. return uParseTime(time, "{y}-{m}-{d}");
  711. },
  712. updatePurchaseOrder() {
  713. if (this.supplier_name == 0 || this.supplier_name == "") {
  714. this.$message.error("供应商不能为空!");
  715. this.loading = false;
  716. return false;
  717. }
  718. this.$refs["tableForm"].validate((valid) => {
  719. if (valid) {
  720. this.loading = true;
  721. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  722. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count);
  723. this.recordInfo.tableList[i].supply_license_number =this.recordInfo.tableList[i].supply_license_number.toString();
  724. this.recordInfo.tableList[i].supply_total_price = (this.recordInfo.tableList[i].supply_count *this.recordInfo.tableList[i].supply_price).toString();
  725. this.recordInfo.tableList[i].supply_total =this.recordInfo.tableList[i].supply_total.toString();
  726. this.recordInfo.tableList[i].supply_price = this.recordInfo.tableList[i].supply_price.toString();
  727. for (let j = 0; j < this.manufactuerList.length; j++) {
  728. if (
  729. this.recordInfo.tableList[i].supply_manufacturer ==
  730. this.manufactuerList[j].id
  731. ) {
  732. this.recordInfo.tableList[i].supply_manufacturer =
  733. this.manufactuerList[j].manufacturer_name;
  734. }
  735. if (
  736. this.recordInfo.tableList[i].supply_manufacturer ==
  737. this.manufactuerList[j].manufacturer_name
  738. ) {
  739. this.recordInfo.tableList[i].manufacturer_id =
  740. this.manufactuerList[j].id;
  741. }
  742. }
  743. }
  744. var start = this.start_time;
  745. var end = this.end_time;
  746. const params = {
  747. stockIn: this.recordInfo.tableList,
  748. return_remake: this.return_remark,
  749. };
  750. updatePurchaseOrder(
  751. params,
  752. this.supplier_name,
  753. start,
  754. end,
  755. this.rate_of_concession,
  756. this.discount_amount,
  757. this.id,
  758. this.number
  759. ).then((response) => {
  760. if (response.data.state == 1) {
  761. this.loading = false;
  762. var warehousingInfo = response.data.data.warehousingInfo;
  763. this.$message.success("保存成功!");
  764. }
  765. });
  766. }
  767. });
  768. },
  769. getAllPrice() {
  770. var total_price = 0;
  771. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  772. total_price +=
  773. this.recordInfo.tableList[i].supply_price *
  774. this.recordInfo.tableList[i].supply_count;
  775. }
  776. this.total_price = total_price;
  777. this.addressChange()
  778. return total_price.toFixed(2);
  779. },
  780. checkPurchaseOrder(id, index) {
  781. this.$confirm("是否审核?", {
  782. confirmButtonText: "确 定",
  783. cancelButtonText: "取 消",
  784. type: "warning",
  785. }).then(() => {
  786. checkPurchaseOrder(this.id).then((response) => {
  787. if (response.data.state == 1) {
  788. var info = response.data.data.info;
  789. this.disabled = true;
  790. this.$message.success("审核成功!");
  791. this.showOne = true;
  792. this.showTwo = false;
  793. this.showThree = true;
  794. this.getPurchaseOrderDetail();
  795. }
  796. });
  797. })
  798. .catch(() => {});
  799. },
  800. getPurchaseOrderDetail() {
  801. var id = this.$route.query.id;
  802. getPurchaseOrderDetail(id).then((response) => {
  803. if (response.data.state == 1) {
  804. var info = response.data.data.info;
  805. if (info.is_check == 1) {
  806. this.Reviewed = true;
  807. }
  808. this.is_check = info.is_check;
  809. this.number = info.number;
  810. this.return_remark = info.return_remake;
  811. this.id = info.id;
  812. this.supplier_name = info.supplier_id;
  813. this.rate_of_concession = info.rate_of_concession;
  814. this.discount_amount = info.discount_amount;
  815. this.start_time = this.getTimes(info.document_date);
  816. this.end_time = this.getTimes(info.delivery_date);
  817. var orderInfo = response.data.data.orderInfo;
  818. if (info.is_check == 2) {
  819. this.disabled = false;
  820. this.showOne = false;
  821. this.showTwo = true;
  822. this.showThree = false;
  823. }
  824. if (info.is_check == 1) {
  825. this.disabled = true;
  826. this.showOne = true;
  827. this.showTwo = false;
  828. this.showThree = true;
  829. }
  830. var drugList = response.data.data.baseList;
  831. var goodList = response.data.data.goodList;
  832. for (let i = 0; i < orderInfo.length; i++) {
  833. orderInfo[i].supply_count = orderInfo[i].count;
  834. orderInfo[i].supply_price = orderInfo[i].price;
  835. orderInfo[i].supply_remake = orderInfo[i].remark;
  836. orderInfo[i].type = orderInfo[i].is_source;
  837. orderInfo[i].project_id = orderInfo[i].project_id;
  838. orderInfo[i].supply_unit = orderInfo[i].supply_unit;
  839. if (orderInfo[i].is_source == 1) {
  840. for (let j = 0; j < drugList.length; j++) {
  841. if (orderInfo[i].project_id == drugList[j].id) {
  842. if (drugList[j].max_unit != drugList[j].min_unit) {
  843. orderInfo[i].unitList = [
  844. { id: 1, name: "" },
  845. { id: 2, name: "" },
  846. ];
  847. orderInfo[i].unitList[0].name = drugList[j].max_unit;
  848. orderInfo[i].unitList[1].name = drugList[j].min_unit;
  849. }
  850. if (drugList[j].max_unit == drugList[j].min_unit) {
  851. orderInfo[i].unitList = [{ id: 1, name: "" }];
  852. orderInfo[i].unitList[0].name = drugList[j].max_unit;
  853. }
  854. }
  855. }
  856. }
  857. if (orderInfo[i].is_source == 2) {
  858. for (let j = 0; j < goodList.length; j++) {
  859. if (orderInfo[i].project_id == goodList[j].id) {
  860. orderInfo[i].unitList = [{ id: 1, name: "" }];
  861. orderInfo[i].unitList[0].name = goodList[j].packing_unit;
  862. }
  863. }
  864. }
  865. }
  866. this.recordInfo.tableList = [];
  867. this.recordInfo.tableList = orderInfo;
  868. }
  869. });
  870. },
  871. toPrint() {
  872. var id = this.$route.query.id;
  873. this.$router.push({ path: "/purchase/order/print?&id=" + id });
  874. },
  875. toAdd() {
  876. var id = this.$route.query.id;
  877. if (this.is_check == 2) {
  878. this.$message.error("该采购订单未审核,不能生成采购数据!");
  879. return false;
  880. }
  881. //获取商品购货订单 和 购货单的总数量
  882. getAllOrderCountList(id).then((response) => {
  883. if (response.data.state == 1) {
  884. var purcaseOrder = response.data.data.purcaseOrder;
  885. var goodOrder = response.data.data.goodOrder;
  886. var drugList = response.data.data.drugList;
  887. var ids = "";
  888. // 如果采购单没有数据,则代表改订单第一次生成采购订单数据
  889. if (goodOrder.length == 0) {
  890. this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + ids});
  891. }
  892. for (let i = 0; i < purcaseOrder.length; i++) {
  893. for (let j = 0; j < drugList.length; j++) {
  894. if (purcaseOrder[i].is_source == 1) {
  895. if (purcaseOrder[i].supply_unit == drugList[j].max_unit) {
  896. purcaseOrder[i].count = purcaseOrder[i].count * drugList[j].min_number;
  897. }
  898. }
  899. }
  900. }
  901. for (let i = 0; i < goodOrder.length; i++) {
  902. for (let j = 0; j < drugList.length; j++) {
  903. if (goodOrder[i].is_source == 1) {
  904. if (goodOrder[i].supply_unit == drugList[j].max_unit) {
  905. goodOrder[i].count = goodOrder[i].count * drugList[j].min_number;
  906. }
  907. }
  908. }
  909. }
  910. let objInfo = {};
  911. if (goodOrder.length > 0) {
  912. goodOrder.forEach((item, index) => {
  913. let { project_id } = item;
  914. if (!objInfo[project_id]) {
  915. objInfo[project_id] = {
  916. project_id,
  917. child: [],
  918. count: 0,
  919. };
  920. }
  921. });
  922. let newArr = Object.values(objInfo);
  923. for (let i = 0; i < goodOrder.length; i++) {
  924. for (let j = 0; j < newArr.length; j++) {
  925. if (goodOrder[i].project_id == newArr[j].project_id) {
  926. newArr[j].child.push(goodOrder[i]);
  927. }
  928. }
  929. }
  930. for (let i = 0; i < newArr.length; i++) {
  931. for (let j = 0; j < newArr[i].child.length; j++) {
  932. newArr[i].count += newArr[i].child[j].count;
  933. }
  934. }
  935. var arr = [];
  936. var total = 0;
  937. var str = "";
  938. //如果采购单有数据,则需要比较数量
  939. if (newArr.length > 0) {
  940. for (let i = 0; i < purcaseOrder.length; i++) {
  941. for (let j = 0; j < newArr.length; j++) {
  942. if (purcaseOrder[i].project_id == newArr[j].project_id) {
  943. //根据商品ID比较数量大小,把数量不足的商品ID储存,表示采购单的数量未满足采购订单的数据,可以继续生成采购单
  944. if (purcaseOrder[i].count > newArr[j].count) {
  945. arr.push(purcaseOrder[i].project_id);
  946. }
  947. }
  948. }
  949. }
  950. //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
  951. if (arr.length == 0) {
  952. this.$message.error("该订单已全部生成采购单,请知悉!");
  953. return;
  954. }
  955. if (arr.length >0) {
  956. str = arr.join(",");
  957. this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + str});
  958. }
  959. }
  960. }
  961. }
  962. });
  963. },
  964. addressChange() {
  965. if (this.rate_of_concession > 0) {
  966. this.discount_amount = (
  967. (this.rate_of_concession / 100) *
  968. this.total_price
  969. ).toFixed(2);
  970. }
  971. },
  972. checkReturnOrder() {
  973. var id = this.$route.query.id;
  974. //获取购货订单号
  975. getGoodOrderList(id).then((response) => {
  976. if (response.data.state == 1) {
  977. var list = response.data.data.list
  978. this.orderList = list
  979. //如果长度大于0,有购货单不能反审核
  980. if (list.length > 0) {
  981. this.$refs.Popup.dialogVisible = true
  982. return
  983. }
  984. if (list.length == 0) {
  985. this.getReturnOrder()
  986. this.showOne = false
  987. this.showTwo = true
  988. this.showThree = false
  989. }
  990. }
  991. });
  992. },
  993. getReturnOrder() {
  994. var id = this.$route.query.id;
  995. getReturnOrder(id).then((response) => {
  996. if (response.data.state == 1) {
  997. var msg = response.data.data.msg;
  998. this.disabled = false;
  999. this.Reviewed = false
  1000. this.$message.success("反审核成功!");
  1001. this.getPurchaseOrderDetail();
  1002. }
  1003. });
  1004. },
  1005. toClick(id) {
  1006. this.$router.push({path:"/good/order/edit?id=" + id});
  1007. },
  1008. },
  1009. created() {
  1010. const tempObj = {};
  1011. tempObj["id"] = 0;
  1012. tempObj["name"] = "";
  1013. tempObj["supply_name"] = "";
  1014. tempObj["supply_type"] = "";
  1015. tempObj["supply_specification_name"] = "";
  1016. tempObj["supply_total"] = "";
  1017. tempObj["supply_count"] = "";
  1018. tempObj["supply_price"] = "";
  1019. tempObj["supply_total_price"] = "";
  1020. tempObj["supply_manufacturer"] = "";
  1021. tempObj["supply_license_number"] = "";
  1022. tempObj["supply_remake"] = "";
  1023. tempObj["type"] = 0;
  1024. tempObj["is_total"] = 1;
  1025. tempObj["project_id"] = 0;
  1026. tempObj["supply_unit"] = "";
  1027. tempObj["manufacturer_id"] = "";
  1028. this.recordInfo.tableList.push(tempObj);
  1029. this.getInitOrder();
  1030. this.getPurchaseOrderDetail();
  1031. },
  1032. };
  1033. </script>
  1034. <style rel="stylesheet/css" lang="scss" scoped>
  1035. .information {
  1036. border: 1px #dcdfe6 solid;
  1037. padding: 30px 20px 30px 20px;
  1038. .border {
  1039. border-bottom: 1px #dcdfe6 solid;
  1040. margin: 0px 0 20px 0;
  1041. }
  1042. }
  1043. .title {
  1044. background: #409eff;
  1045. height: 44px;
  1046. line-height: 44px;
  1047. padding: 0 0 0 10px;
  1048. color: #fff;
  1049. margin: 0 0 10px 0;
  1050. }
  1051. .edit_separater {
  1052. border-top: 1px solid rgb(233, 233, 233);
  1053. margin-top: 15px;
  1054. margin-bottom: 15px;
  1055. }
  1056. </style>
  1057. <style>
  1058. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1059. font-size: 12px;
  1060. }
  1061. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1062. background: #6fb5fa;
  1063. }
  1064. .count {
  1065. color: #bd2c00;
  1066. }
  1067. .el-table td,
  1068. .el-table th.is-leaf,
  1069. .el-table--border,
  1070. .el-table--group {
  1071. border-color: #d0d3da;
  1072. }
  1073. .el-table--border::after,
  1074. .el-table--group::after,
  1075. .el-table::before {
  1076. background-color: #d0d3da;
  1077. }
  1078. .el-table__fixed-right {
  1079. width: 150px;
  1080. bottom: 20px;
  1081. height: 100%;
  1082. }
  1083. .reviewImg {
  1084. position: fixed;
  1085. left: 50%;
  1086. transform: translateX(-50%);
  1087. top: 30%;
  1088. }
  1089. </style>