addPurchaseOrder.vue 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218
  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: 220px; 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 style="display:flex;">
  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="showSix"
  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. deletePurchOder
  368. } from "@/api/supply";
  369. import { getDataConfig } from "@/utils/data";
  370. export default {
  371. name: "addPurchaseOrder",
  372. components: {
  373. BreadCrumb,
  374. },
  375. data() {
  376. return {
  377. Reviewed: false,
  378. crumbs: [
  379. { path: false, name: "采购订单" },
  380. { path: "/spply/query", name: "新增采购订单" },
  381. ],
  382. showTwo: true,
  383. showOne: false,
  384. showThree:false,
  385. recordInfo: {
  386. tableList: [],
  387. },
  388. keywords: "",
  389. total: 0,
  390. multipleSelection: [],
  391. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  392. start_time: "",
  393. end_time: "",
  394. page: 1,
  395. limit: 10,
  396. goodType: [],
  397. goodInfo: [],
  398. org_id: 0,
  399. types: [],
  400. tyep_name: "",
  401. form: {
  402. manufacturer_id: "",
  403. },
  404. tabList: [],
  405. manufactuerList: [],
  406. currentIndex: 0,
  407. goodTypeList: [],
  408. drugTypeList: [],
  409. supplier_name: "",
  410. supplyList: [],
  411. rate_of_concession: "",
  412. discount_amount: "",
  413. start_time: new Date(),
  414. end_time: new Date(),
  415. tableRules: {
  416. name: [{ required: true, message: "商品不能为空", trigger: "blur" }],
  417. supply_count: [
  418. { required: true, message: "数量不能为空", trigger: "blur" },
  419. ],
  420. supply_unit: [
  421. { required: true, message: "单位不能为空", trigger: "blur" },
  422. ],
  423. },
  424. warehousing_id: 0,
  425. number: "",
  426. loading: false,
  427. drugList: [],
  428. goodList: [],
  429. id: 0,
  430. disabled: false,
  431. unitList: [
  432. { id: 1, name: "" },
  433. { id: 2, name: "" },
  434. ],
  435. goodList: [{ id: 1, name: "" }],
  436. total_price: 0,
  437. return_remark: "",
  438. is_check: 2,
  439. showSix:false,
  440. };
  441. },
  442. watch: {
  443. total_price: function (newval, oldval) {
  444. if (this.rate_of_concession != "") {
  445. this.addressChange();
  446. }
  447. },
  448. },
  449. methods: {
  450. getInitOrder() {
  451. getInitOrder().then((response) => {
  452. if (response.data.state == 1) {
  453. var drugList = response.data.data.drugList;
  454. this.manufactuerList = response.data.data.manufactuerList;
  455. this.goodTypeList = response.data.data.goodTypeList;
  456. this.drugTypeList = response.data.data.drugTypeList;
  457. this.supplyList = response.data.data.supplyList;
  458. for (let i = 0; i < drugList.length; i++) {
  459. for (let z = 0; z < drugList[i].drug_warehouse_info.length; z++) {
  460. if (
  461. drugList[i].max_unit ==
  462. drugList[i].drug_warehouse_info[z].max_unit
  463. ) {
  464. drugList[i].drug_warehouse_info[z].stock_max_number =
  465. drugList[i].drug_warehouse_info[z].stock_max_number *
  466. drugList[i].min_number;
  467. }
  468. }
  469. for (let j = 0; j < this.manufactuerList.length; j++) {
  470. if (drugList[i].manufacturer == this.manufactuerList[j].id) {
  471. drugList[i].manufacturer =
  472. this.manufactuerList[j].manufacturer_name;
  473. }
  474. }
  475. for (let y = 0; y < this.drugTypeList.length; y++) {
  476. if (drugList[i].drug_type == this.drugTypeList[y].value) {
  477. drugList[i].drug_type = this.drugTypeList[y].name;
  478. }
  479. }
  480. drugList[i].supply_name =
  481. drugList[i].drug_name +
  482. " " +
  483. drugList[i].dose +
  484. drugList[i].dose_unit +
  485. "*" +
  486. drugList[i].min_number +
  487. drugList[i].min_unit +
  488. "/" +
  489. drugList[i].max_unit +
  490. " " +
  491. drugList[i].manufacturer;
  492. drugList[i].supply_type = drugList[i].drug_type;
  493. drugList[i].supply_specification_name =
  494. drugList[i].dose +
  495. drugList[i].dose_unit +
  496. "*" +
  497. drugList[i].min_number +
  498. drugList[i].min_unit +
  499. "/" +
  500. drugList[i].max_unit;
  501. drugList[i].supply_total = this.getWarehoseInfo(
  502. drugList[i].drug_warehouse_info,
  503. drugList[i].max_unit,
  504. drugList[i].min_unit,
  505. drugList[i].min_number
  506. );
  507. drugList[i].supply_count = "";
  508. drugList[i].supply_total_price = "";
  509. drugList[i].supply_manufacturer = drugList[i].manufacturer;
  510. drugList[i].supply_license_number = drugList[i].number;
  511. drugList[i].supply_remake = "";
  512. drugList[i].type = 1;
  513. drugList[i].supply_price = drugList[i].last_price;
  514. drugList[i].name = drugList[i].drug_name;
  515. if (drugList[i].max_unit != drugList[i].min_unit) {
  516. drugList[i].unitList = [
  517. { id: 1, name: "" },
  518. { id: 2, name: "" },
  519. ];
  520. }
  521. if (drugList[i].max_unit == drugList[i].min_unit) {
  522. drugList[i].unitList = [{ id: 1, name: "" }];
  523. }
  524. drugList[i].supply_unit = drugList[i].max_unit;
  525. for (let j = 0; j < drugList[i].unitList.length; j++) {
  526. if (drugList[i].max_unit != drugList[i].min_unit) {
  527. drugList[i].unitList[0].name = drugList[i].max_unit;
  528. drugList[i].unitList[1].name = drugList[i].min_unit;
  529. }
  530. if (drugList[i].max_unit == drugList[i].min_unit) {
  531. drugList[i].unitList[0].name = drugList[i].max_unit;
  532. }
  533. }
  534. this.tabList.push(drugList[i]);
  535. }
  536. this.drugList = drugList;
  537. var goodList = response.data.data.goodList;
  538. for (let i = 0; i < goodList.length; i++) {
  539. for (let j = 0; j < this.manufactuerList.length; j++) {
  540. if (goodList[i].manufacturer == this.manufactuerList[j].id) {
  541. goodList[i].manufacturer =
  542. this.manufactuerList[j].manufacturer_name;
  543. }
  544. }
  545. for (let y = 0; y < this.goodTypeList.length; y++) {
  546. if (goodList[i].good_type_id == this.goodTypeList[y].id) {
  547. goodList[i].good_type_id = this.goodTypeList[y].type_name;
  548. }
  549. }
  550. goodList[i].supply_name =
  551. goodList[i].good_name +
  552. " " +
  553. goodList[i].specification_name +
  554. " " +
  555. goodList[i].manufacturer;
  556. goodList[i].supply_type = goodList[i].good_type_id;
  557. goodList[i].supply_specification_name =
  558. goodList[i].specification_name;
  559. goodList[i].supply_price = goodList[i].buy_price;
  560. goodList[i].supply_total = this.getTotalStockCount(
  561. goodList[i].good_warehouse_info
  562. );
  563. goodList[i].supply_count = "";
  564. goodList[i].supply_total_price = "";
  565. goodList[i].supply_manufacturer = goodList[i].manufacturer;
  566. goodList[i].supply_license_number = goodList[i].number;
  567. goodList[i].supply_remake = "";
  568. goodList[i].type = 2;
  569. goodList[i].name = goodList[i].good_name;
  570. goodList[i].unitList = [{ id: 1, name: "" }];
  571. goodList[i].supply_unit = goodList[i].packing_unit;
  572. for (let j = 0; j < goodList[i].unitList.length; j++) {
  573. goodList[i].unitList[0].name = goodList[i].packing_unit;
  574. }
  575. this.tabList.push(goodList[i]);
  576. }
  577. this.goodList = goodList;
  578. }
  579. });
  580. },
  581. changeGoodName(val) {
  582. this.currentIndex = val;
  583. },
  584. changeName(val) {
  585. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  586. if (this.currentIndex == i) {
  587. this.recordInfo.tableList[i].project_id = val.id;
  588. this.recordInfo.tableList[i].type = val.type;
  589. this.recordInfo.tableList[i].name = val.name;
  590. this.recordInfo.tableList[i].supply_name = val.supply_name;
  591. this.recordInfo.tableList[i].supply_type = val.supply_type;
  592. this.recordInfo.tableList[i].supply_specification_name =
  593. val.supply_specification_name;
  594. this.recordInfo.tableList[i].supply_total = val.supply_total;
  595. if (val.supply_count == NaN) {
  596. this.recordInfo.tableList[i].supply_count = "";
  597. } else {
  598. this.recordInfo.tableList[i].supply_count = val.supply_count
  599. ? val.supply_count
  600. : "";
  601. }
  602. this.recordInfo.tableList[i].supply_price = val.supply_price
  603. ? val.supply_price
  604. : "";
  605. this.recordInfo.tableList[i].supply_total_price =
  606. val.supply_total_price ? val.supply_total_price : "";
  607. this.recordInfo.tableList[i].supply_manufacturer =
  608. val.supply_manufacturer;
  609. this.recordInfo.tableList[i].supply_license_number =
  610. val.supply_license_number;
  611. this.recordInfo.tableList[i].supply_remake = val.supply_remake;
  612. this.recordInfo.tableList[i].is_total = val.is_total;
  613. this.recordInfo.tableList[i].supply_unit = val.supply_unit;
  614. this.recordInfo.tableList[i].unitList = val.unitList;
  615. }
  616. }
  617. },
  618. handleEdit() {
  619. const tempObj = {};
  620. tempObj["id"] = 0;
  621. tempObj["name"] = "";
  622. tempObj["supply_name"] = "";
  623. tempObj["supply_type"] = "";
  624. tempObj["supply_specification_name"] = "";
  625. tempObj["supply_total"] = "";
  626. tempObj["supply_count"] = "";
  627. tempObj["supply_price"] = "";
  628. tempObj["supply_total_price"] = "";
  629. tempObj["supply_manufacturer"] = "";
  630. tempObj["supply_license_number"] = "";
  631. tempObj["supply_remake"] = "";
  632. tempObj["type"] = 0;
  633. tempObj["is_total"] = 1;
  634. tempObj["project_id"] = 0;
  635. tempObj["supply_unit"] = "";
  636. tempObj["manufacturer_id"] = "";
  637. this.recordInfo.tableList.push(tempObj);
  638. },
  639. handleDelete: function (index, row) {
  640. if (this.recordInfo.tableList.length <= 1) {
  641. this.$message.error("只有一条记录的时候无法删除");
  642. return;
  643. } else {
  644. this.recordInfo.tableList.splice(index, 1);
  645. }
  646. if(row.id > 0){
  647. const params = {
  648. id: row.id,
  649. };
  650. this.$confirm("确认删除吗?", {
  651. confirmButtonText: "确定",
  652. cancelButtonText: "取消",
  653. type: "warning",
  654. }).then(() => {
  655. deletePurchOder(params).then((response) => {
  656. if (response.data.state == 0) {
  657. this.$message.error(response.data.msg);
  658. return false;
  659. } else {
  660. this.$message.success("删除成功");
  661. this.recordInfo.tableList.splice(index, 1);
  662. }
  663. });
  664. }).catch(() => {});
  665. }
  666. },
  667. savePurchaseOrder() {
  668. if (this.supplier_name == 0 || this.supplier_name == "") {
  669. this.$message.error("供应商不能为空!");
  670. this.loading = false;
  671. return false;
  672. }
  673. this.$refs["tableForm"].validate((valid) => {
  674. if (valid) {
  675. this.loading = true;
  676. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  677. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count);
  678. this.recordInfo.tableList[i].supply_license_number =this.recordInfo.tableList[i].supply_license_number.toString();
  679. this.recordInfo.tableList[i].supply_total_price = (this.recordInfo.tableList[i].supply_count *this.recordInfo.tableList[i].supply_price ).toString();
  680. this.recordInfo.tableList[i].supply_total = this.recordInfo.tableList[i].supply_total.toString();
  681. this.recordInfo.tableList[i].supply_price = this.recordInfo.tableList[i].supply_price.toString();
  682. for (let j = 0; j < this.manufactuerList.length; j++) {
  683. if (
  684. this.recordInfo.tableList[i].supply_manufacturer ==
  685. this.manufactuerList[j].manufacturer_name
  686. ) {
  687. this.recordInfo.tableList[i].manufacturer_id =
  688. this.manufactuerList[j].id;
  689. }
  690. }
  691. }
  692. var start = this.getTimes(this.start_time);
  693. var end = this.getTimes(this.end_time);
  694. const params = {
  695. stockIn: this.recordInfo.tableList,
  696. return_remake: this.return_remark,
  697. };
  698. savePurchaseOrder(
  699. params,
  700. this.supplier_name,
  701. start,
  702. end,
  703. this.rate_of_concession,
  704. this.discount_amount
  705. ).then((response) => {
  706. if (response.data.state == 1) {
  707. var order = response.data.data.order;
  708. this.loading = false;
  709. this.showSix = true
  710. this.$message.success("保存成功!");
  711. var warehouseInfo = response.data.data.warehouseInfo;
  712. this.is_check = warehouseInfo.is_check;
  713. if (warehouseInfo.is_check == 1) {
  714. this.Reviewed = true;
  715. }
  716. this.number = warehouseInfo.number;
  717. this.id = warehouseInfo.id;
  718. this.recordInfo.tableList = [];
  719. this.return_remark = warehouseInfo.return_remake;
  720. var orderInfo = response.data.data.orderInfo;
  721. console.log("orderINO23323332232323",orderInfo)
  722. for (let i = 0; i < orderInfo.length; i++) {
  723. if (orderInfo[i].is_source == 1) {
  724. for (let j = 0; j < this.drugList.length; j++) {
  725. if (orderInfo[i].project_id == this.drugList[j].id) {
  726. orderInfo[i].unitList = [
  727. { id: 1, name: "" },
  728. { id: 2, name: "" },
  729. ];
  730. orderInfo[i].unitList[0].name = this.drugList[j].max_unit;
  731. orderInfo[i].unitList[1].name = this.drugList[j].min_unit;
  732. }
  733. }
  734. }
  735. if (orderInfo[i].is_source == 2) {
  736. for (let j = 0; j < this.goodList.length; j++) {
  737. if (orderInfo[i].project_id == this.goodList[j].id) {
  738. orderInfo[i].unitList = [{ id: 1, name: "" }];
  739. orderInfo[i].unitList[0].name = this.goodList[j].packing_unit;
  740. }
  741. }
  742. }
  743. orderInfo[i].id = orderInfo[i].id
  744. orderInfo[i].name = orderInfo[i].name
  745. orderInfo[i].supply_count = orderInfo[i].count;
  746. orderInfo[i].supply_price = orderInfo[i].price;
  747. orderInfo[i].supply_remake = orderInfo[i].remark;
  748. orderInfo[i].type = orderInfo[i].is_source;
  749. orderInfo[i].project_id = orderInfo[i].project_id;
  750. orderInfo[i].supply_unit = orderInfo[i].supply_unit;
  751. orderInfo[i].supply_specification_name = orderInfo[i].supply_specification_name
  752. orderInfo[i].supply_total = orderInfo[i].supply_total
  753. }
  754. this.recordInfo.tableList = orderInfo;
  755. console.log("orderInfo2332322323232332",orderInfo)
  756. // for (let i = 0; i < orderInfo.length; i++) {
  757. // orderInfo[i].name = "";
  758. // orderInfo[i].supply_name = "";
  759. // orderInfo[i].supply_specification_name = "";
  760. // if (orderInfo[i].is_source == 1) {
  761. // for (let j = 0; j < this.drugList.length; j++) {
  762. // if (orderInfo[i].project_id == this.drugList[j].id) {
  763. // orderInfo[i].name = this.drugList[j].drug_name;
  764. // }
  765. // }
  766. // }
  767. // if (orderInfo[i].is_source == 2) {
  768. // for (let y = 0; y < this.goodList.length; y++) {
  769. // if ((orderInfo[i].project_id = this.goodList[y].id)) {
  770. // orderInfo[i].name = this.goodList[y].good_name;
  771. // }
  772. // }
  773. // }
  774. // }
  775. this.showTwo = false;
  776. this.showOne = true;
  777. this.showThree = true
  778. }
  779. });
  780. }
  781. });
  782. },
  783. getWarehoseInfo(arr, max_unit, min_unit, min_number) {
  784. var total = 0;
  785. var max_str = "";
  786. var min_str = "";
  787. if (arr.length > 0) {
  788. for (let i = 0; i < arr.length; i++) {
  789. total += parseInt(arr[i].stock_max_number + arr[i].stock_min_number);
  790. }
  791. }
  792. if (total < min_number) {
  793. min_str = total + min_unit;
  794. }
  795. if (total == 0) {
  796. min_str = "";
  797. max_str = "";
  798. }
  799. if (total >= min_number) {
  800. if (parseInt(total / min_number) != 0) {
  801. max_str = parseInt(total / min_number) + max_unit;
  802. }
  803. if (total % min_number != 0) {
  804. min_str = (total % min_number) + min_unit;
  805. }
  806. }
  807. return max_str + min_str;
  808. },
  809. getTotalStockCount(arr) {
  810. var total_count = 0;
  811. for (let i = 0; i < arr.length; i++) {
  812. total_count += arr[i].stock_count;
  813. }
  814. return total_count;
  815. },
  816. calculate: function (val) {
  817. if (isNaN(val)) {
  818. return "";
  819. }
  820. if (val == 0) {
  821. return "";
  822. }
  823. return Math.round(parseFloat(val) * 100) / 100;
  824. },
  825. getTimes(time) {
  826. if (time === "") {
  827. return "";
  828. }
  829. return uParseTime(time, "{y}-{m}-{d}");
  830. },
  831. updatePurchaseOrder() {
  832. if (this.supplier_name == 0 || this.supplier_name == "") {
  833. this.$message.error("供应商不能为空!");
  834. this.loading = false;
  835. return false;
  836. }
  837. this.$refs["tableForm"].validate((valid) => {
  838. if (valid) {
  839. this.loading = true;
  840. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  841. this.recordInfo.tableList[i].supply_count = parseInt(
  842. this.recordInfo.tableList[i].supply_count
  843. );
  844. this.recordInfo.tableList[i].supply_license_number =
  845. this.recordInfo.tableList[i].supply_license_number.toString();
  846. this.recordInfo.tableList[i].supply_total_price = (
  847. this.recordInfo.tableList[i].supply_count *
  848. this.recordInfo.tableList[i].supply_price
  849. ).toString();
  850. this.recordInfo.tableList[i].supply_total =
  851. this.recordInfo.tableList[i].supply_total.toString();
  852. this.recordInfo.tableList[i].supply_price =
  853. this.recordInfo.tableList[i].supply_price.toString();
  854. for (let j = 0; j < this.manufactuerList.length; j++) {
  855. if (this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].id ) {
  856. this.recordInfo.tableList[i].supply_manufacturer = this.manufactuerList[j].manufacturer_name;
  857. }
  858. if (this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name) {
  859. this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id;
  860. }
  861. }
  862. }
  863. var start = this.getTimes(this.start_time);
  864. var end = this.getTimes(this.end_time);
  865. const params = {
  866. stockIn: this.recordInfo.tableList,
  867. return_remake: this.return_remark,
  868. };
  869. console.log("23223322323",params)
  870. updatePurchaseOrder(
  871. params,
  872. this.supplier_name,
  873. start,
  874. end,
  875. this.rate_of_concession,
  876. this.discount_amount,
  877. this.id,
  878. this.number
  879. ).then((response) => {
  880. if (response.data.state == 1) {
  881. this.loading = false;
  882. var warehousingInfo = response.data.data.warehousingInfo;
  883. var orderInfo = response.data.data.orderInfo
  884. for (let i = 0; i < orderInfo.length; i++) {
  885. orderInfo[i].id = orderInfo[i].id
  886. orderInfo[i].name = orderInfo[i].name
  887. orderInfo[i].supply_count = orderInfo[i].count;
  888. orderInfo[i].supply_price = orderInfo[i].price;
  889. orderInfo[i].supply_remake = orderInfo[i].remark;
  890. orderInfo[i].type = orderInfo[i].is_source;
  891. orderInfo[i].project_id = orderInfo[i].project_id;
  892. orderInfo[i].supply_unit = orderInfo[i].supply_unit;
  893. orderInfo[i].supply_specification_name = orderInfo[i].supply_specification_name
  894. orderInfo[i].supply_total = orderInfo[i].supply_total
  895. }
  896. this.recordInfo.tableList = orderInfo;
  897. this.$message.success("保存成功!");
  898. }
  899. });
  900. }
  901. });
  902. },
  903. getAllPrice() {
  904. var total_price = 0;
  905. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  906. total_price +=
  907. this.recordInfo.tableList[i].supply_price *
  908. this.recordInfo.tableList[i].supply_count;
  909. }
  910. this.total_price = total_price;
  911. // this.discount_amount = (this.total_price * this.rate_of_concession * 0.01).toFixed(2);
  912. return total_price.toFixed(2);
  913. },
  914. count_discount() {
  915. this.rate_of_concession = (
  916. this.discount_amount /
  917. (this.total_price * 0.01)
  918. ).toFixed(2);
  919. },
  920. checkPurchaseOrder(id, index) {
  921. this.$confirm("是否审核?", {
  922. confirmButtonText: "确 定",
  923. cancelButtonText: "取 消",
  924. type: "warning",
  925. })
  926. .then(() => {
  927. checkPurchaseOrder(this.id).then((response) => {
  928. if (response.data.state == 1) {
  929. var info = response.data.data.info;
  930. this.is_check = info.is_check
  931. this.showOne = false
  932. this.showTwo = false
  933. this.showThree = true
  934. this.disabled = true;
  935. this.showSix = true
  936. this.$message.success("审核成功!");
  937. this.Reviewed = true;
  938. }
  939. });
  940. })
  941. .catch(() => {});
  942. },
  943. toPrint() {
  944. var id = this.id;
  945. this.$router.push({ path: "/purchase/order/print?&id=" + id });
  946. },
  947. getDataConfig(module, filed_name) {
  948. return getDataConfig(module, filed_name);
  949. },
  950. addressChange() {
  951. var discount_amount = 0;
  952. if (this.rate_of_concession > 0) {
  953. discount_amount = (
  954. (this.rate_of_concession / 100) *
  955. this.total_price
  956. ).toFixed(2);
  957. }
  958. this.discount_amount = discount_amount;
  959. },
  960. checkReturnOrder() {
  961. var id = this.id;
  962. getReturnOrder(id).then((response) => {
  963. if (response.data.state == 1) {
  964. var msg = response.data.data.msg;
  965. this.disabled = false;
  966. this.showOne = true;
  967. this.is_check = 2;
  968. this.$message.success("反审核成功!");
  969. }
  970. });
  971. },
  972. toAdd() {
  973. if (this.is_check == 2) {
  974. this.$message.error("该采购订单未审核,不能生成采购数据!");
  975. return false;
  976. }
  977. //获取商品购货订单 和 购货单的总数量
  978. getAllOrderCountList(this.id).then((response) => {
  979. if (response.data.state == 1) {
  980. var purcaseOrder = response.data.data.purcaseOrder;
  981. var goodOrder = response.data.data.goodOrder;
  982. var drugList = response.data.data.drugList;
  983. var ids = "";
  984. // 如果采购单没有数据,则代表改订单第一次生成采购订单数据
  985. if (goodOrder.length == 0) {
  986. this.$router.push({path: "/good/order/add?id=" + this.id + "&ids=" + ids});
  987. }
  988. for (let i = 0; i < purcaseOrder.length; i++) {
  989. for (let j = 0; j < drugList.length; j++) {
  990. if (purcaseOrder[i].is_source == 1) {
  991. if (purcaseOrder[i].supply_unit == drugList[j].max_unit) {
  992. purcaseOrder[i].count = purcaseOrder[i].count * drugList[j].min_number;
  993. }
  994. }
  995. }
  996. }
  997. for (let i = 0; i < goodOrder.length; i++) {
  998. for (let j = 0; j < drugList.length; j++) {
  999. if (goodOrder[i].is_source == 1) {
  1000. if (goodOrder[i].supply_unit == drugList[j].max_unit) {
  1001. goodOrder[i].count = goodOrder[i].count * drugList[j].min_number;
  1002. }
  1003. }
  1004. }
  1005. }
  1006. let objInfo = {};
  1007. if (goodOrder.length > 0) {
  1008. goodOrder.forEach((item, index) => {
  1009. let { project_id } = item;
  1010. if (!objInfo[project_id]) {
  1011. objInfo[project_id] = {
  1012. project_id,
  1013. child: [],
  1014. count: 0,
  1015. };
  1016. }
  1017. });
  1018. let newArr = Object.values(objInfo);
  1019. for (let i = 0; i < goodOrder.length; i++) {
  1020. for (let j = 0; j < newArr.length; j++) {
  1021. if (goodOrder[i].project_id == newArr[j].project_id) {
  1022. newArr[j].child.push(goodOrder[i]);
  1023. }
  1024. }
  1025. }
  1026. for (let i = 0; i < newArr.length; i++) {
  1027. for (let j = 0; j < newArr[i].child.length; j++) {
  1028. newArr[i].count += newArr[i].child[j].count;
  1029. }
  1030. }
  1031. var arr = [];
  1032. var total = 0;
  1033. var str = "";
  1034. console.log("长度111",purcaseOrder.length)
  1035. console.log("长度222",goodOrder.length)
  1036. if(purcaseOrder.length <=goodOrder.length){
  1037. //如果采购单有数据,则需要比较数量
  1038. if (newArr.length > 0) {
  1039. for (let i = 0; i < purcaseOrder.length; i++) {
  1040. for (let j = 0; j < newArr.length; j++) {
  1041. if (purcaseOrder[i].project_id == newArr[j].project_id) {
  1042. //根据商品ID比较数量大小,把数量不足的商品ID储存,表示采购单的数量未满足采购订单的数据,可以继续生成采购单
  1043. if (purcaseOrder[i].count > newArr[j].count) {
  1044. arr.push(purcaseOrder[i].project_id);
  1045. }
  1046. }
  1047. }
  1048. }
  1049. //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
  1050. if (arr.length == 0) {
  1051. this.$message.error("该订单已全部生成采购单,请知悉!");
  1052. return;
  1053. }
  1054. if (arr.length >0) {
  1055. str = arr.join(",");
  1056. this.$router.push({path: "/good/order/add?id=" + this.id + "&ids=" + str});
  1057. }
  1058. }
  1059. }
  1060. //如果采购订单的商品个数不等与 采购单里面的商品个数
  1061. if(purcaseOrder.length>goodOrder.length){
  1062. var arrList = []
  1063. var str = "";
  1064. if (newArr.length > 0) {
  1065. for (let i = 0; i < purcaseOrder.length; i++) {
  1066. for (let j = 0; j < newArr.length; j++) {
  1067. //如果采购订单的商品个数不等与 采购单里面的商品个数
  1068. if(purcaseOrder[i].project_id != newArr[j].project_id){
  1069. arrList.push(purcaseOrder[i].project_id)
  1070. }
  1071. }
  1072. }
  1073. //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
  1074. console.log("are232323323223322323",arrList)
  1075. if(arrList.length > 0){
  1076. str = arrList.join(",");
  1077. this.$router.push({path: "/good/order/add?id=" + id + "&ids=" + str});
  1078. }
  1079. }
  1080. }
  1081. }
  1082. }
  1083. });
  1084. },
  1085. },
  1086. created() {
  1087. const tempObj = {};
  1088. tempObj["id"] = 0;
  1089. tempObj["name"] = "";
  1090. tempObj["supply_name"] = "";
  1091. tempObj["supply_type"] = "";
  1092. tempObj["supply_specification_name"] = "";
  1093. tempObj["supply_total"] = "";
  1094. tempObj["supply_count"] = "";
  1095. tempObj["supply_price"] = "";
  1096. tempObj["supply_total_price"] = "";
  1097. tempObj["supply_manufacturer"] = "";
  1098. tempObj["supply_license_number"] = "";
  1099. tempObj["supply_remake"] = "";
  1100. tempObj["type"] = 0;
  1101. tempObj["is_total"] = 1;
  1102. tempObj["project_id"] = 0;
  1103. tempObj["supply_unit"] = "";
  1104. tempObj["manufacturer_id"] = "";
  1105. this.recordInfo.tableList.push(tempObj);
  1106. this.getInitOrder();
  1107. },
  1108. };
  1109. </script>
  1110. <style rel="stylesheet/css" lang="scss" scoped>
  1111. .information {
  1112. border: 1px #dcdfe6 solid;
  1113. padding: 30px 20px 30px 20px;
  1114. .border {
  1115. border-bottom: 1px #dcdfe6 solid;
  1116. margin: 0px 0 20px 0;
  1117. }
  1118. }
  1119. .title {
  1120. background: #409eff;
  1121. height: 44px;
  1122. line-height: 44px;
  1123. padding: 0 0 0 10px;
  1124. color: #fff;
  1125. margin: 0 0 10px 0;
  1126. }
  1127. .edit_separater {
  1128. border-top: 1px solid rgb(233, 233, 233);
  1129. margin-top: 15px;
  1130. margin-bottom: 15px;
  1131. }
  1132. .reviewImg {
  1133. position: fixed;
  1134. left: 50%;
  1135. transform: translateX(-50%);
  1136. top: 30%;
  1137. }
  1138. /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  1139. width: 15px !important;
  1140. height: 15px !important;
  1141. }
  1142. </style>
  1143. <style>
  1144. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1145. font-size: 12px;
  1146. }
  1147. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1148. background: #6fb5fa;
  1149. }
  1150. .count {
  1151. color: #bd2c00;
  1152. }
  1153. .el-table td,
  1154. .el-table th.is-leaf,
  1155. .el-table--border,
  1156. .el-table--group {
  1157. border-color: #d0d3da;
  1158. }
  1159. .el-table--border::after,
  1160. .el-table--group::after,
  1161. .el-table::before {
  1162. background-color: #d0d3da;
  1163. }
  1164. .el-table__fixed-right {
  1165. width: 150px;
  1166. bottom: 20px;
  1167. height: 100%;
  1168. }
  1169. </style>