Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

addPurchaseOrder.vue 38KB

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