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

addGoodOrder.vue 57KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605
  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 style="display:flex;align-items: center;">
  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. :disabled="disabled"
  22. >
  23. <el-option
  24. v-for="item in supplyList"
  25. :key="item.id"
  26. :label="item.supplier_name"
  27. :value="item.id"
  28. >
  29. </el-option>
  30. </el-select>
  31. <span>单据日期:</span>
  32. <el-date-picker
  33. :disabled="disabled"
  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. ></el-date-picker>
  45. <!-- <span>交货日期:</span> -->
  46. <!-- <el-date-picker
  47. size="small"
  48. v-model="end_time"
  49. prefix-icon="el-icon-date"
  50. :editable="false"
  51. style="width: 196px;"
  52. type="date"
  53. placeholder="选择日期时间"
  54. align="right"
  55. format="yyyy-MM-dd"
  56. value-format="yyyy-MM-dd"
  57. @change="endTimeChange"
  58. ></el-date-picker> -->
  59. <span>单据编码:{{ good_number }}</span>
  60. </div>
  61. <div style="display:flex">
  62. <el-button
  63. size="small"
  64. type="primary"
  65. @click="saveGoodOrder"
  66. v-show="showOne"
  67. >保存</el-button
  68. >
  69. <el-button
  70. size="small"
  71. type="primary"
  72. @click="updateGoodOrder"
  73. v-show="showTwo"
  74. >保存</el-button
  75. >
  76. <el-button size="small" type="primary" @click="checkGoodOrder" v-if="is_check == 2" >审核</el-button>
  77. <el-button size="small" type="primary" @click="MofyGoodOrder" v-if="is_check == 1">反审核</el-button>
  78. <el-button size="small" type="primary" @click="toClick" v-if="is_check == 1" >生成采购退货单</el-button>
  79. </div>
  80. </div>
  81. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  82. <el-table
  83. :row-style="{ color: '#303133' }"
  84. :header-cell-style="{
  85. backgroundColor: 'rgb(245, 247, 250)',
  86. color: '#606266',
  87. }"
  88. :data="recordInfo.tableList"
  89. :class="signAndWeighBoxPatients"
  90. border
  91. style="width: 100%"
  92. max-height="450"
  93. >
  94. <el-table-column align="center" width="200px">
  95. <template slot="header" slot-scope="scope">
  96. <span>商品<span style="color: red">*</span></span>
  97. </template>
  98. <template slot-scope="scope">
  99. <el-form-item
  100. :prop="'tableList.' + scope.$index + '.name'"
  101. :rules="tableRules.name"
  102. >
  103. <el-select
  104. v-model="scope.row.name"
  105. style="width: 160px"
  106. filterable
  107. placeholder="请选择商品"
  108. @change="changeName"
  109. @input="changeGoodName(scope.$index)"
  110. :disabled="disabled"
  111. >
  112. <el-option
  113. v-for="(item, index) in tabList"
  114. :key="index"
  115. :label="item.supply_name"
  116. :value="item"
  117. >
  118. </el-option>
  119. </el-select>
  120. </el-form-item>
  121. </template>
  122. </el-table-column>
  123. <el-table-column align="center" width="150px">
  124. <template slot="header" slot-scope="scope">
  125. <span>商品类别</span>
  126. </template>
  127. <template slot-scope="scope">
  128. <el-input
  129. v-model="scope.row.supply_type"
  130. style="width: 120px"
  131. :disabled="true"
  132. placeholder="商品类别"
  133. ></el-input>
  134. <div style="visibility: hidden">/</div>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="规格&单位" align="center" width="150px">
  138. <template slot-scope="scope">
  139. <el-input
  140. v-model="scope.row.supply_specification_name"
  141. style="width: 120px"
  142. :disabled="true"
  143. placeholder="规格&单位"
  144. ></el-input>
  145. <div style="visibility: hidden">/</div>
  146. </template>
  147. </el-table-column>
  148. <el-table-column label="单位" align="center" width="120px">
  149. <template slot="header" slot-scope="scope">
  150. <span>单位<span style="color: red">*</span></span>
  151. </template>
  152. <template slot-scope="scope">
  153. <el-form-item
  154. :prop="'tableList.' + scope.$index + '.supply_unit'"
  155. :rules="tableRules.supply_unit"
  156. >
  157. <el-select
  158. v-model="scope.row.supply_unit"
  159. style="width: 100px"
  160. filterable
  161. placeholder="请选择"
  162. :disabled="disabled"
  163. >
  164. <el-option
  165. v-for="(item, index) in scope.row.unitList"
  166. :key="index"
  167. :label="item.name"
  168. :value="item.name"
  169. >
  170. </el-option>
  171. </el-select>
  172. </el-form-item>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="批号" align="center" width="200px">
  176. <template slot="header" slot-scope="scope">
  177. <span>批号<span style="color: red">*</span></span>
  178. </template>
  179. <template slot-scope="scope">
  180. <el-form-item
  181. :prop="'tableList.' + scope.$index + '.supply_batch_number'"
  182. :rules="tableRules.supply_batch_number"
  183. >
  184. <el-input
  185. v-model="scope.row.supply_batch_number"
  186. style="width: 180px"
  187. :disabled="disabled"
  188. placeholder="请输入批号"
  189. ></el-input>
  190. </el-form-item>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="有效日期" align="center" width="200px">
  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_expiry_date'"
  200. :rules="tableRules.supply_expiry_date"
  201. >
  202. <el-date-picker
  203. prefix-icon="el-icon-date"
  204. style="width: 180px"
  205. v-model="scope.row.supply_expiry_date"
  206. type="date"
  207. placeholder="选择日期时间"
  208. format="yyyy-MM-dd"
  209. value-format="yyyy-MM-dd"
  210. >
  211. </el-date-picker>
  212. </el-form-item>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="可用库存" align="center" width="150px">
  216. <template slot-scope="scope">
  217. <el-input
  218. v-model="scope.row.supply_total"
  219. style="width: 100px"
  220. :disabled="true"
  221. ></el-input>
  222. <div style="visibility: hidden">/</div>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="数量" align="center" width="140px">
  226. <template slot="header" slot-scope="scope">
  227. <span>数量<span style="color: red">*</span></span>
  228. </template>
  229. <template slot-scope="scope">
  230. <el-form-item
  231. :prop="'tableList.' + scope.$index + '.supply_count'"
  232. :rules="tableRules.supply_count"
  233. >
  234. <el-input
  235. v-model="scope.row.supply_count"
  236. style="width: 100px"
  237. :disabled="disabled"
  238. placeholder="请输入数量"
  239. ></el-input>
  240. </el-form-item>
  241. </template>
  242. </el-table-column>
  243. <el-table-column label="拆零零售价" align="center" width="180px">
  244. <template slot-scope="scope">
  245. <el-input
  246. v-model="scope.row.min_price"
  247. style="width: 140px"
  248. :disabled="disabled"
  249. placeholder="请输入拆零零售价"
  250. ></el-input>
  251. <div style="visibility: hidden">/</div>
  252. </template>
  253. </el-table-column>
  254. <el-table-column label="采购单价" align="center" width="180px">
  255. <template slot-scope="scope">
  256. <el-input
  257. v-model="scope.row.supply_price"
  258. style="width: 140px"
  259. :disabled="disabled"
  260. placeholder="请输入采购单价"
  261. ></el-input>
  262. <div style="visibility: hidden">/</div>
  263. </template>
  264. </el-table-column>
  265. <el-table-column label="采购金额" align="center" width="120px">
  266. <template slot-scope="scope">
  267. {{ calculate(scope.row.supply_count * scope.row.supply_price) }}
  268. <div style="visibility: hidden">/</div>
  269. </template>
  270. </el-table-column>
  271. <el-table-column label="生产日期" align="center" width="200px">
  272. <template slot="header" slot-scope="scope">
  273. <span>生产日期<span style="color: red">*</span></span>
  274. </template>
  275. <template slot-scope="scope">
  276. <el-form-item
  277. :prop="'tableList.' + scope.$index + '.supply_product_date'"
  278. :rules="tableRules.supply_product_date"
  279. >
  280. <el-date-picker
  281. prefix-icon="el-icon-date"
  282. style="width: 180px"
  283. v-model="scope.row.supply_product_date"
  284. type="date"
  285. placeholder="选择日期时间"
  286. format="yyyy-MM-dd"
  287. value-format="yyyy-MM-dd"
  288. >
  289. </el-date-picker>
  290. </el-form-item>
  291. </template>
  292. </el-table-column>
  293. <el-table-column label="生产厂家" align="center" width="200px">
  294. <template slot-scope="scope">
  295. <el-select
  296. size="small"
  297. v-model="scope.row.supply_manufacturer"
  298. filterable
  299. :disabled="true"
  300. >
  301. <el-option
  302. v-for="(option, index) in manufactuerList"
  303. :key="index"
  304. :label="option.manufacturer_name"
  305. :value="option.id"
  306. >
  307. </el-option>
  308. </el-select>
  309. <div style="visibility: hidden">/</div>
  310. </template>
  311. </el-table-column>
  312. <el-table-column label="批准文号" align="center" width="200px">
  313. <template slot-scope="scope">
  314. <el-input
  315. v-model="scope.row.supply_license_number"
  316. style="width: 160px"
  317. :disabled="true"
  318. ></el-input>
  319. <div style="visibility: hidden">/</div>
  320. </template>
  321. </el-table-column>
  322. <el-table-column label="关联采购订单号" align="center" width="200px">
  323. <template slot-scope="scope">
  324. <el-input
  325. v-model="scope.row.order_number"
  326. style="width: 160px"
  327. :disabled="true"
  328. ></el-input>
  329. <div style="visibility: hidden">/</div>
  330. </template>
  331. </el-table-column>
  332. <el-table-column label="备注" align="center" width="200px">
  333. <template slot-scope="scope">
  334. <el-input
  335. v-model="scope.row.supply_remake"
  336. style="width: 160px"
  337. :disabled="disabled"
  338. placeholder="请输入备注"
  339. ></el-input>
  340. <div style="visibility: hidden">/</div>
  341. </template>
  342. </el-table-column>
  343. <el-table-column
  344. label="操作"
  345. align="center"
  346. width="150px"
  347. fixed="right"
  348. >
  349. <template slot-scope="scope">
  350. <el-tooltip
  351. class="item"
  352. effect="dark"
  353. content="新增"
  354. placement="top"
  355. >
  356. <el-button
  357. size="mini"
  358. type="primary"
  359. icon="el-icon-circle-plus-outline"
  360. @click="handleEdit(scope.$index, scope.row)"
  361. >
  362. </el-button>
  363. </el-tooltip>
  364. <el-tooltip
  365. class="item"
  366. effect="dark"
  367. content="删除"
  368. placement="top"
  369. >
  370. <el-button
  371. size="mini"
  372. type="danger"
  373. icon="el-icon-delete"
  374. @click="handleDelete(scope.$index, scope.row)"
  375. >
  376. </el-button>
  377. </el-tooltip>
  378. </template>
  379. </el-table-column>
  380. </el-table>
  381. <div style="margin-top: 10px">
  382. <el-input
  383. type="textarea"
  384. :rows="2"
  385. placeholder="备注信息"
  386. v-model="return_remark"
  387. >
  388. </el-input>
  389. </div>
  390. </el-form>
  391. <div>
  392. <div style="margin-top: 10px">合计:{{ getAllPrice() }} 元</div>
  393. <div style="margin-top: 10px">
  394. <span
  395. >优惠率:<el-input
  396. style="width: 150px"
  397. v-model="rate_of_concession"
  398. @input="addressChange"
  399. placeholder="请输入优惠率"
  400. :disabled="disabled"
  401. ></el-input
  402. >%</span
  403. >
  404. <span
  405. >优惠金额:<el-input
  406. style="width: 150px"
  407. v-model="discount_amount"
  408. @input="count_discount"
  409. placeholder="请输入优惠金额"
  410. :disabled="disabled"
  411. ></el-input
  412. ></span>
  413. <span
  414. >本次付款:<el-input
  415. style="width: 150px"
  416. v-model="payment"
  417. @input="count_payment"
  418. placeholder="请输入本次付款"
  419. :disabled="disabled"
  420. ></el-input
  421. ></span>
  422. <span
  423. >本次欠款:<el-input
  424. style="width: 150px"
  425. v-model="arrearage"
  426. @input="count_arrearage"
  427. placeholder="请输入本次欠款"
  428. :disabled="disabled"
  429. ></el-input
  430. ></span>
  431. </div>
  432. </div>
  433. <!-- <Computed :total="total_price" :rate_of_concession="rate_of_concession" :discount_amount="discount_amount"></Computed> -->
  434. </div>
  435. <!-- <el-dialog
  436. title="提示"
  437. :visible.sync="dialogVisible"
  438. width="30%"
  439. :before-close="handleClose">
  440. <span>这是一段信息</span>
  441. <span slot="footer" class="dialog-footer">
  442. <el-button @click="dialogVisible = false">取 消</el-button>
  443. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  444. </span>
  445. </el-dialog> -->
  446. </div>
  447. </template>
  448. <script>
  449. import Computed from "../../components/Computed/index_1.vue";
  450. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  451. import { uParseTime } from "@/utils/tools";
  452. import {
  453. getInitOrder,
  454. checkPurchaseOrder,
  455. getPurchaseOrderInfo,
  456. addGoodOrder,
  457. updateGoodOrder,
  458. checkGoodOrderById,
  459. getGoodOrderCountList,
  460. ModefySupplyWarehousing,
  461. MofyGoodOrder,
  462. getSupplyWarehouseOutById,
  463. UpdateSupplyWahouseingInfo
  464. } from "@/api/supply";
  465. export default {
  466. name: "addPurchaseOrder",
  467. components: {
  468. BreadCrumb,
  469. Computed,
  470. },
  471. data() {
  472. return {
  473. crumbs: [
  474. { path: false, name: "采购单" },
  475. { path: "/supply/good/order/query", name: "新增采购单" },
  476. ],
  477. showTwo: true,
  478. showOne: false,
  479. recordInfo: {
  480. tableList: [],
  481. },
  482. keywords: "",
  483. total: 0,
  484. multipleSelection: [],
  485. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  486. start_time: "",
  487. end_time: "",
  488. page: 1,
  489. limit: 10,
  490. goodType: [],
  491. goodInfo: [],
  492. org_id: 0,
  493. types: [],
  494. tyep_name: "",
  495. form: {
  496. manufacturer_id: "",
  497. },
  498. tabList: [],
  499. manufactuerList: [],
  500. currentIndex: 0,
  501. goodTypeList: [],
  502. drugTypeList: [],
  503. supplier_name: "",
  504. supplyList: [],
  505. total_price: 0,
  506. rate_of_concession: "",
  507. discount_amount: "",
  508. start_time: "",
  509. end_time: "",
  510. tableRules: {
  511. name: [{ required: true, message: "商品不能为空", trigger: "blur" }],
  512. supply_count: [
  513. { required: true, message: "数量不能为空", trigger: "blur" },
  514. ],
  515. supply_batch_number: [
  516. { required: true, message: "批号不能为空", trigger: "blur" },
  517. ],
  518. supply_product_date: [
  519. { required: true, message: "生产日期不能为空", trigger: "blur" },
  520. ],
  521. supply_expiry_date: [
  522. { required: true, message: "有效日期不能为空", trigger: "blur" },
  523. ],
  524. },
  525. warehousing_id: 0,
  526. number: "",
  527. loading: false,
  528. drugList: [],
  529. goodList: [],
  530. id: 0,
  531. disabled: false,
  532. is_check: 0,
  533. dialogVisible: false,
  534. arrearage: "",
  535. payment: "",
  536. good_number: "",
  537. orderInfo: [],
  538. showOne: true,
  539. showTwo: false,
  540. warese_out_id: 0,
  541. return_remark: "",
  542. is_warehouse:0,
  543. tableDataList:[]
  544. };
  545. },
  546. watch: {
  547. total_price: function (newval, oldval) {
  548. if(this.rate_of_concession != ""){
  549. this.addressChange()
  550. }
  551. }
  552. },
  553. methods: {
  554. getInitOrder() {
  555. getInitOrder().then((response) => {
  556. if (response.data.state == 1) {
  557. var drugList = response.data.data.drugList;
  558. this.manufactuerList = response.data.data.manufactuerList;
  559. this.goodTypeList = response.data.data.goodTypeList;
  560. this.drugTypeList = response.data.data.drugTypeList;
  561. this.supplyList = response.data.data.supplyList;
  562. for (let i = 0; i < drugList.length; i++) {
  563. for (let z = 0; z < drugList[i].drug_warehouse_info.length; z++) {
  564. if (drugList[i].max_unit == drugList[i].drug_warehouse_info[z].max_unit) {
  565. drugList[i].drug_warehouse_info[z].stock_max_number = drugList[i].drug_warehouse_info[z].stock_max_number *drugList[i].min_number;
  566. }
  567. }
  568. for (let j = 0; j < this.manufactuerList.length; j++) {
  569. if (drugList[i].manufacturer == this.manufactuerList[j].id) {
  570. drugList[i].manufacturer =
  571. this.manufactuerList[j].manufacturer_name;
  572. }
  573. }
  574. for (let y = 0; y < this.drugTypeList.length; y++) {
  575. if (drugList[i].drug_type == this.drugTypeList[y].value) {
  576. drugList[i].drug_type = this.drugTypeList[y].name;
  577. }
  578. }
  579. drugList[i].supply_name =
  580. drugList[i].drug_name +
  581. " " +
  582. drugList[i].dose +
  583. drugList[i].dose_unit +
  584. "*" +
  585. drugList[i].min_number +
  586. drugList[i].min_unit +
  587. "/" +
  588. drugList[i].max_unit +
  589. " " +
  590. drugList[i].manufacturer;
  591. drugList[i].supply_type = drugList[i].drug_type;
  592. drugList[i].supply_specification_name =
  593. drugList[i].dose +
  594. drugList[i].dose_unit +
  595. "*" +
  596. drugList[i].min_number +
  597. drugList[i].min_unit +
  598. "/" +
  599. drugList[i].max_unit;
  600. drugList[i].supply_total = this.getWarehoseInfo(
  601. drugList[i].drug_warehouse_info,
  602. drugList[i].max_unit,
  603. drugList[i].min_unit,
  604. drugList[i].min_number
  605. );
  606. drugList[i].supply_count = "";
  607. drugList[i].supply_total_price = "";
  608. drugList[i].supply_manufacturer = drugList[i].manufacturer;
  609. drugList[i].supply_license_number = drugList[i].number;
  610. drugList[i].supply_remake = "";
  611. drugList[i].type = 1;
  612. drugList[i].supply_price = drugList[i].last_price;
  613. drugList[i].min_price = drugList[i].min_price
  614. drugList[i].name = drugList[i].drug_name;
  615. if (drugList[i].max_unit != drugList[i].min_unit) {
  616. drugList[i].unitList = [
  617. { id: 1, name: "" },
  618. { id: 2, name: "" },
  619. ];
  620. }
  621. if (drugList[i].max_unit == drugList[i].min_unit) {
  622. drugList[i].unitList = [{ id: 1, name: "" }];
  623. }
  624. drugList[i].supply_unit = drugList[i].max_unit;
  625. for (let j = 0; j < drugList[i].unitList.length; j++) {
  626. if (drugList[i].max_unit != drugList[i].min_unit) {
  627. drugList[i].unitList[0].name = drugList[i].max_unit;
  628. drugList[i].unitList[1].name = drugList[i].min_unit;
  629. }
  630. if (drugList[i].max_unit == drugList[i].min_unit) {
  631. drugList[i].unitList[0].name = drugList[i].max_unit;
  632. }
  633. }
  634. this.tabList.push(drugList[i]);
  635. }
  636. this.drugList = drugList;
  637. var goodList = response.data.data.goodList;
  638. for (let i = 0; i < goodList.length; i++) {
  639. for (let j = 0; j < this.manufactuerList.length; j++) {
  640. if (goodList[i].manufacturer == this.manufactuerList[j].id) {
  641. goodList[i].manufacturer =
  642. this.manufactuerList[j].manufacturer_name;
  643. }
  644. }
  645. for (let y = 0; y < this.goodTypeList.length; y++) {
  646. if (goodList[i].good_type_id == this.goodTypeList[y].id) {
  647. goodList[i].good_type_id = this.goodTypeList[y].type_name;
  648. }
  649. }
  650. goodList[i].supply_name =goodList[i].good_name +" " +goodList[i].specification_name + " " +
  651. goodList[i].manufacturer;
  652. goodList[i].supply_type = goodList[i].good_type_id;
  653. goodList[i].supply_specification_name =
  654. goodList[i].specification_name;
  655. goodList[i].supply_price = goodList[i].buy_price;
  656. goodList[i].supply_total = this.getTotalStockCount(
  657. goodList[i].good_warehouse_info
  658. );
  659. goodList[i].supply_count = "";
  660. goodList[i].supply_total_price = "";
  661. goodList[i].supply_manufacturer = goodList[i].manufacturer;
  662. goodList[i].supply_license_number = goodList[i].number;
  663. goodList[i].supply_remake = "";
  664. goodList[i].type = 2;
  665. goodList[i].name = goodList[i].good_name;
  666. goodList[i].unitList = [{ id: 1, name: "" }];
  667. goodList[i].supply_unit = goodList[i].packing_unit;
  668. goodList[i].min_price = goodList[i].retail_price
  669. for (let j = 0; j < goodList[i].unitList.length; j++) {
  670. goodList[i].unitList[0].name = goodList[i].packing_unit;
  671. }
  672. this.tabList.push(goodList[i]);
  673. }
  674. this.goodList = goodList;
  675. }
  676. });
  677. },
  678. changeGoodName(val) {
  679. console.log("val2332232323323",val)
  680. this.currentIndex = val;
  681. },
  682. changeName(val) {
  683. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  684. if (this.currentIndex == i) {
  685. this.recordInfo.tableList[i].project_id = val.id;
  686. this.recordInfo.tableList[i].type = val.type;
  687. this.recordInfo.tableList[i].name = val.name;
  688. this.recordInfo.tableList[i].supply_name = val.supply_name;
  689. this.recordInfo.tableList[i].supply_type = val.supply_type;
  690. this.recordInfo.tableList[i].supply_specification_name = val.supply_specification_name;
  691. this.recordInfo.tableList[i].supply_total = val.supply_total;
  692. this.recordInfo.tableList[i].min_price = val.min_price
  693. if (val.supply_count == NaN) {
  694. this.recordInfo.tableList[i].supply_count = "";
  695. } else {
  696. this.recordInfo.tableList[i].supply_count = val.supply_count
  697. ? val.supply_count
  698. : "";
  699. }
  700. this.recordInfo.tableList[i].supply_price = val.supply_price
  701. ? val.supply_price
  702. : "";
  703. this.recordInfo.tableList[i].supply_total_price = (
  704. val.supply_count * val.supply_price
  705. ).toFixed(2);
  706. this.recordInfo.tableList[i].supply_manufacturer =
  707. val.supply_manufacturer;
  708. this.recordInfo.tableList[i].supply_license_number =
  709. val.supply_license_number;
  710. this.recordInfo.tableList[i].supply_remake = val.supply_remake;
  711. this.recordInfo.tableList[i].is_total = val.is_total;
  712. this.recordInfo.tableList[i].supply_unit = val.supply_unit;
  713. this.recordInfo.tableList[i].unitList = val.unitList;
  714. }
  715. }
  716. },
  717. handleEdit() {
  718. const tempObj = {};
  719. tempObj["id"] = 0;
  720. tempObj["name"] = "";
  721. tempObj["supply_name"] = "";
  722. tempObj["supply_type"] = "";
  723. tempObj["supply_specification_name"] = "";
  724. tempObj["supply_total"] = "";
  725. tempObj["supply_count"] = "";
  726. tempObj["supply_price"] = "";
  727. tempObj["supply_total_price"] = "";
  728. tempObj["supply_manufacturer"] = "";
  729. tempObj["supply_license_number"] = "";
  730. tempObj["supply_remake"] = "";
  731. tempObj["type"] = 0;
  732. tempObj["is_total"] = 1;
  733. tempObj["project_id"] = 0;
  734. tempObj["supply_unit"] = "";
  735. tempObj["supply_batch_number"] = "";
  736. tempObj["supply_product_date"] = "";
  737. tempObj["order_number"] = "";
  738. tempObj["supply_expiry_date"] = "";
  739. tempObj["manufacturer_id"] = "";
  740. tempObj["min_price"] = ""
  741. tempObj["warehouse_info_id"] = 0
  742. tempObj["warehousing_id"] = 0
  743. this.recordInfo.tableList.push(tempObj);
  744. },
  745. handleDelete: function (index, row) {
  746. if (this.recordInfo.tableList.length <= 1) {
  747. this.$message.error("只有一条记录的时候无法删除");
  748. return;
  749. } else {
  750. this.recordInfo.tableList.splice(index, 1);
  751. }
  752. },
  753. getWarehoseInfo(arr, max_unit, min_unit, min_number) {
  754. var total = 0;
  755. var max_str = "";
  756. var min_str = "";
  757. if (arr.length > 0) {
  758. for (let i = 0; i < arr.length; i++) {
  759. total += parseInt(arr[i].stock_max_number + arr[i].stock_min_number);
  760. }
  761. }
  762. if (total < min_number) {
  763. min_str = total + min_unit;
  764. }
  765. if (total == 0) {
  766. min_str = "";
  767. max_str = "";
  768. }
  769. if (total >= min_number) {
  770. if (parseInt(total / min_number) != 0) {
  771. max_str = parseInt(total / min_number) + max_unit;
  772. }
  773. if (total % min_number != 0) {
  774. min_str = (total % min_number) + min_unit;
  775. }
  776. }
  777. return max_str + min_str;
  778. },
  779. getTotalStockCount(arr) {
  780. var total_count = 0;
  781. for (let i = 0; i < arr.length; i++) {
  782. total_count += arr[i].stock_count;
  783. }
  784. if(total_count >0){
  785. return total_count;
  786. }else{
  787. return ""
  788. }
  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. getAllPrice() {
  806. var total_price = 0;
  807. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  808. total_price +=
  809. this.recordInfo.tableList[i].supply_price *
  810. this.recordInfo.tableList[i].supply_count;
  811. }
  812. this.total_price = total_price;
  813. // this.discount_amount = (this.total_price * this.rate_of_concession * 0.01).toFixed(2);
  814. return total_price.toFixed(2);
  815. },
  816. addressChange() {
  817. var discount_amount = 0;
  818. if (this.rate_of_concession > 0) {
  819. discount_amount = (
  820. (this.rate_of_concession / 100) *
  821. this.total_price
  822. ).toFixed(2);
  823. }
  824. this.discount_amount = discount_amount;
  825. },
  826. count_discount() {
  827. this.rate_of_concession = (
  828. this.discount_amount /
  829. (this.total_price * 0.01)
  830. ).toFixed(2);
  831. },
  832. count_payment() {
  833. let arrearage_1 = (this.total_price - this.discount_amount - this.payment).toFixed(2);
  834. if(arrearage_1 > 0){
  835. this.arrearage = arrearage_1
  836. }else{
  837. this.arrearage = 0
  838. }
  839. },
  840. count_arrearage() {
  841. this.payment = this.total_price - this.arrearage;
  842. },
  843. // checkPurchaseOrder() {
  844. // this.$confirm("是否审核?", {
  845. // confirmButtonText: "确 定",
  846. // cancelButtonText: "取 消",
  847. // type: "warning",
  848. // }).then(() => {
  849. // checkPurchaseOrder(this.id).then((response) => {
  850. // if (response.data.state == 1) {
  851. // var info = response.data.data.info;
  852. // this.disabled = true;
  853. // this.$message.success("审核成功!");
  854. // this.getPurchaseOrderDetail();
  855. // }
  856. // });
  857. // })
  858. // .catch(() => {});
  859. // },
  860. getPurchaseOrderDetail() {
  861. var id = this.$route.query.id;
  862. var ids = this.$route.query.ids;
  863. getPurchaseOrderInfo(id, ids).then((response) => {
  864. if (response.data.state == 1) {
  865. var info = response.data.data.info;
  866. console.log("采购订单ID")
  867. this.id = info.id;
  868. this.supplier_name = info.supplier_id;
  869. this.rate_of_concession = info.rate_of_concession;
  870. this.discount_amount = info.discount_amount;
  871. this.number = info.number;
  872. var orderInfo = response.data.data.orderInfo;
  873. for (let i = 0; i < orderInfo.length; i++) {
  874. orderInfo[i].supply_batch_number = "";
  875. orderInfo[i].supply_product_date = "";
  876. orderInfo[i].supply_expiry_date = "";
  877. }
  878. var drugList = response.data.data.baseList;
  879. var goodList = response.data.data.goodList;
  880. for (let i = 0; i < orderInfo.length; i++) {
  881. orderInfo[i].supply_count = orderInfo[i].count;
  882. orderInfo[i].supply_price = orderInfo[i].price;
  883. orderInfo[i].supply_remake = orderInfo[i].remark;
  884. orderInfo[i].type = orderInfo[i].is_source;
  885. orderInfo[i].project_id = orderInfo[i].project_id;
  886. orderInfo[i].supply_unit = orderInfo[i].supply_unit;
  887. orderInfo[i].order_number = orderInfo[i].order_number;
  888. orderInfo[i].min_price = ""
  889. orderInfo[i].supply_total_price = (orderInfo[i].count * orderInfo[i].price).toFixed(2);
  890. if (orderInfo[i].is_source == 1) {
  891. for (let j = 0; j < drugList.length; j++) {
  892. if (orderInfo[i].project_id == drugList[j].id) {
  893. if (drugList[j].max_unit != drugList[j].min_unit) {
  894. orderInfo[i].unitList = [
  895. { id: 1, name: "" },
  896. { id: 2, name: "" },
  897. ];
  898. orderInfo[i].unitList[0].name = drugList[j].max_unit;
  899. orderInfo[i].unitList[1].name = drugList[j].min_unit;
  900. }
  901. if (drugList[j].max_unit == drugList[j].min_unit) {
  902. orderInfo[i].unitList = [{ id: 1, name: "" }];
  903. orderInfo[i].unitList[0].name = drugList[j].max_unit;
  904. }
  905. }
  906. }
  907. }
  908. if (orderInfo[i].is_source == 2) {
  909. for (let j = 0; j < goodList.length; j++) {
  910. if (orderInfo[i].project_id == goodList[j].id) {
  911. orderInfo[i].unitList = [{ id: 1, name: "" }];
  912. orderInfo[i].unitList[0].name = goodList[j].packing_unit;
  913. }
  914. }
  915. }
  916. }
  917. this.recordInfo.tableList = [];
  918. this.recordInfo.tableList = orderInfo;
  919. //用来判断是否删除了从采购订单的数据
  920. this.tableDataList = []
  921. this.tableDataList = orderInfo
  922. console.log("changed23323232233232",this.tableDataList)
  923. }
  924. });
  925. },
  926. toPrint() {
  927. var id = this.$route.query.id;
  928. this.$router.push({ path: "/purchase/order/print?&id=" + id });
  929. },
  930. saveGoodOrder() {
  931. if (this.supplier_name == 0 || this.supplier_name == "") {
  932. this.$message.error("供应商不能为空!");
  933. this.loading = false;
  934. return false;
  935. }
  936. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  937. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count);
  938. this.recordInfo.tableList[i].supply_price =
  939. this.recordInfo.tableList[i].supply_price.toString();
  940. this.recordInfo.tableList[i].supply_total_price =
  941. this.recordInfo.tableList[i].supply_total_price.toString();
  942. this.recordInfo.tableList[i].supply_total =
  943. this.recordInfo.tableList[i].supply_total.toString();
  944. this.recordInfo.tableList[i].min_price = this.recordInfo.tableList[i].min_price.toString()
  945. for (let j = 0; j < this.manufactuerList.length; j++) {
  946. if (
  947. this.recordInfo.tableList[i].supply_manufacturer ==
  948. this.manufactuerList[j].manufacturer_name
  949. ) {
  950. this.recordInfo.tableList[i].manufacturer_id =
  951. this.manufactuerList[j].id;
  952. }
  953. if (
  954. this.recordInfo.tableList[i].supply_manufacturer ==
  955. this.manufactuerList[j].id
  956. ) {
  957. this.recordInfo.tableList[i].supply_manufacturer =
  958. this.manufactuerList[j].manufacturer_name;
  959. }
  960. }
  961. }
  962. var start = this.start_time;
  963. this.$refs["tableForm"].validate((valid) => {
  964. if (valid) {
  965. this.loading = true;
  966. var warehousing_id = this.$route.query.id;
  967. //判断是否在采购订单数据中做了删除,如果长度相等则代表没有删除,如果不等则代表做了删除或者新增
  968. console.log("原数据",this.tableDataList)
  969. console.log("新数据",this.recordInfo.tableList)
  970. if(this.tableDataList.length > this.recordInfo.tableList.length){
  971. warehousing_id = 0
  972. for(let i=0;i<this.recordInfo.tableList.length;i++){
  973. this.recordInfo.tableList[i].id = 0
  974. this.number = ""
  975. }
  976. }
  977. var params = {
  978. stockIn: this.recordInfo.tableList,
  979. return_remake: this.return_remark,
  980. };
  981. // return
  982. addGoodOrder( params,this.supplier_name,start,this.arrearage,this.payment, warehousing_id,this.number,this.rate_of_concession,this.discount_amount).then((response) => {
  983. if (response.data.state == 1) {
  984. this.loading = false;
  985. this.$message.success("保存成功!");
  986. this.showOne = false;
  987. this.showTwo = true;
  988. var orderInfo = response.data.data.list;
  989. var warehouseOut = response.data.data.warehouseOut;
  990. this.is_check = 2
  991. this.warese_out_id = warehouseOut.id;
  992. console.log("采购单id2322332",this.warese_out_id)
  993. this.good_number = warehouseOut.good_number;
  994. this.rate_of_concession = warehouseOut.rate_of_concession;
  995. this.discount_amount = warehouseOut.discount_amount;
  996. this.payment = warehouseOut.payment;
  997. this.arrearage = warehouseOut.arrearage;
  998. this.supplier_name = warehouseOut.supplier_id;
  999. this.return_remake = warehouseOut.return_remake;
  1000. this.warehousing_id = warehouseOut.warehousing_id
  1001. this.start_time = this.getTimes(warehouseOut.document_date);
  1002. for (let i = 0; i < orderInfo.length; i++) {
  1003. orderInfo[i].supply_count = orderInfo[i].count;
  1004. orderInfo[i].supply_price = orderInfo[i].price;
  1005. orderInfo[i].supply_remake = orderInfo[i].remark;
  1006. orderInfo[i].type = orderInfo[i].is_source;
  1007. orderInfo[i].project_id = orderInfo[i].project_id;
  1008. orderInfo[i].supply_unit = orderInfo[i].supply_unit;
  1009. orderInfo[i].order_number = orderInfo[i].order_number;
  1010. orderInfo[i].warehouse_info_id = orderInfo[i].warehouse_info_id
  1011. orderInfo[i].warehousing_id = orderInfo[i].warehousing_id
  1012. orderInfo[i].supply_total_price = (
  1013. orderInfo[i].count * orderInfo[i].price
  1014. ).toFixed(2);
  1015. orderInfo[i].supply_expiry_date = this.getTimes(
  1016. orderInfo[i].supply_expiry_date
  1017. );
  1018. orderInfo[i].supply_product_date = this.getTimes(
  1019. orderInfo[i].supply_product_date
  1020. );
  1021. if (orderInfo[i].is_source == 1) {
  1022. for (let j = 0; j < this.drugList.length; j++) {
  1023. if (orderInfo[i].project_id == this.drugList[j].id) {
  1024. if (this.drugList[j].max_unit != this.drugList[j].min_unit) {
  1025. orderInfo[i].unitList = [{ id: 1, name: "" },{ id: 2, name: "" }];
  1026. orderInfo[i].unitList[0].name = this.drugList[j].max_unit;
  1027. orderInfo[i].unitList[1].name = this.drugList[j].min_unit;
  1028. }
  1029. if (this.drugList[j].max_unit == this.drugList[j].min_unit) {
  1030. orderInfo[i].unitList[0].name = this.drugList[j].max_unit;
  1031. }
  1032. }
  1033. }
  1034. }
  1035. if (orderInfo[i].is_source == 2) {
  1036. for (let j = 0; j < this.goodList.length; j++) {
  1037. if (orderInfo[i].project_id == this.goodList[j].id) {
  1038. orderInfo[i].unitList = [{ id: 1, name: "" }];
  1039. orderInfo[i].unitList[0].name = this.goodList[j].packing_unit;
  1040. }
  1041. }
  1042. }
  1043. }
  1044. this.recordInfo.tableList = [];
  1045. this.recordInfo.tableList = orderInfo;
  1046. }
  1047. });
  1048. }
  1049. });
  1050. },
  1051. updateGoodOrder() {
  1052. if (this.supplier_name == 0 || this.supplier_name == "") {
  1053. this.$message.error("供应商不能为空!");
  1054. this.loading = false;
  1055. return false;
  1056. }
  1057. for (let i = 0; i < this.recordInfo.tableList.length; i++) {
  1058. this.recordInfo.tableList[i].supply_count = parseInt(
  1059. this.recordInfo.tableList[i].supply_count
  1060. );
  1061. this.recordInfo.tableList[i].supply_price =
  1062. this.recordInfo.tableList[i].supply_price.toString();
  1063. this.recordInfo.tableList[i].supply_total_price =
  1064. this.recordInfo.tableList[i].supply_total_price.toString();
  1065. this.recordInfo.tableList[i].supply_total =
  1066. this.recordInfo.tableList[i].supply_total.toString();
  1067. this.recordInfo.tableList[i].min_price = this.recordInfo.tableList[i].min_price.toString()
  1068. for (let j = 0; j < this.manufactuerList.length; j++) {
  1069. if (
  1070. this.recordInfo.tableList[i].supply_manufacturer ==
  1071. this.manufactuerList[j].manufacturer_name
  1072. ) {
  1073. this.recordInfo.tableList[i].manufacturer_id =
  1074. this.manufactuerList[j].id;
  1075. }
  1076. if (
  1077. this.recordInfo.tableList[i].supply_manufacturer ==
  1078. this.manufactuerList[j].id
  1079. ) {
  1080. this.recordInfo.tableList[i].supply_manufacturer =
  1081. this.manufactuerList[j].manufacturer_name;
  1082. }
  1083. }
  1084. }
  1085. var start = this.start_time;
  1086. this.$refs["tableForm"].validate((valid) => {
  1087. if (valid) {
  1088. this.loading = true;
  1089. var warehose_out_id = this.$route.query.id;
  1090. var params = {
  1091. stockIn: this.recordInfo.tableList,
  1092. return_remake: this.return_remake,
  1093. };
  1094. console.log("param232332",params)
  1095. updateGoodOrder(
  1096. params,
  1097. this.supplier_name,
  1098. start,
  1099. this.arrearage,
  1100. this.payment,
  1101. warehose_out_id,
  1102. this.number,
  1103. this.rate_of_concession,
  1104. this.discount_amount,
  1105. this.good_number
  1106. ).then((response) => {
  1107. if (response.data.state == 1) {
  1108. this.loading = false;
  1109. this.$message.success("保存成功!");
  1110. }
  1111. });
  1112. }
  1113. });
  1114. },
  1115. checkGoodOrder() {
  1116. var id = this.warese_out_id;
  1117. var warehousing_id = this.id;
  1118. console.log("采购单ID",id)
  1119. console.log("采购订单ID",warehousing_id)
  1120. this.loading = true
  1121. getGoodOrderCountList(id, warehousing_id).then((response) => {
  1122. if (response.data.state == 1) {
  1123. this.$message.success("审核成功!");
  1124. this.disabled = true
  1125. this.is_check = 1
  1126. this.showOne = false;
  1127. this.showTwo = true;
  1128. this.showThree = true;
  1129. this.loading = false
  1130. var purcaseOrder = response.data.data.purcaseOrder;
  1131. var goodOrder = response.data.data.goodOrder;
  1132. var drugList = response.data.data.drugList;
  1133. var is_warehouse = 0;
  1134. for (let i = 0; i < purcaseOrder.length; i++) {
  1135. for (let j = 0; j < drugList.length; j++) {
  1136. if (purcaseOrder[i].is_source == 1) {
  1137. if (purcaseOrder[i].supply_unit == drugList[j].max_unit) {
  1138. purcaseOrder[i].count =
  1139. purcaseOrder[i].count * drugList[j].min_number;
  1140. }
  1141. }
  1142. }
  1143. }
  1144. for (let i = 0; i < goodOrder.length; i++) {
  1145. for (let j = 0; j < drugList.length; j++) {
  1146. if (goodOrder[i].is_source == 1) {
  1147. if (goodOrder[i].supply_unit == drugList[j].max_unit) {
  1148. goodOrder[i].count =
  1149. goodOrder[i].count * drugList[j].min_number;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. let objInfo = {};
  1155. if (goodOrder.length > 0) {
  1156. goodOrder.forEach((item, index) => {
  1157. let { project_id } = item;
  1158. if (!objInfo[project_id]) {
  1159. objInfo[project_id] = {
  1160. project_id,
  1161. child: [],
  1162. count: 0,
  1163. };
  1164. }
  1165. });
  1166. let newArr = Object.values(objInfo);
  1167. for (let i = 0; i < goodOrder.length; i++) {
  1168. for (let j = 0; j < newArr.length; j++) {
  1169. if (goodOrder[i].project_id == newArr[j].project_id) {
  1170. newArr[j].child.push(goodOrder[i]);
  1171. }
  1172. }
  1173. }
  1174. console.log("newAr2332232323", newArr);
  1175. for (let i = 0; i < newArr.length; i++) {
  1176. for (let j = 0; j < newArr[i].child.length; j++) {
  1177. newArr[i].count += newArr[i].child[j].count;
  1178. }
  1179. }
  1180. var arr = [];
  1181. var total = 0;
  1182. var str = "";
  1183. //如果采购单有数据,则需要比较数量
  1184. if (newArr.length > 0) {
  1185. for (let i = 0; i < purcaseOrder.length; i++) {
  1186. for (let j = 0; j < newArr.length; j++) {
  1187. if (purcaseOrder[i].project_id == newArr[j].project_id) {
  1188. //根据商品ID比较数量大小,把数量不足的商品ID储存,表示采购单的数量未满足采购订单的数据,部分入库
  1189. if (purcaseOrder[i].count > newArr[j].count) {
  1190. arr.push(purcaseOrder[i].project_id);
  1191. }
  1192. }
  1193. }
  1194. }
  1195. //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成,全部入库
  1196. console.log("审核长度2332322323323332",arr)
  1197. if (arr.length == 0) {
  1198. this.is_warehouse = 1;
  1199. this.ModefySupplyWarehousing(this.is_warehouse, warehousing_id);
  1200. }
  1201. //部分入库
  1202. if (arr.length > 0) {
  1203. //修改订购单
  1204. this.is_warehouse = 3;
  1205. this.ModefySupplyWarehousing(this.is_warehouse, warehousing_id);
  1206. }
  1207. }
  1208. }
  1209. }
  1210. });
  1211. },
  1212. ModefySupplyWarehousing(is_warehouse, warehousing_id) {
  1213. var params = {
  1214. is_warehouse: this.is_warehouse,
  1215. warehousing_id: this.warehousing_id,
  1216. };
  1217. ModefySupplyWarehousing(params).then((response) => {
  1218. if (response.data.state == 1) {
  1219. var msg = response.data.data.msg;
  1220. }
  1221. });
  1222. },
  1223. MofyGoodOrder() {
  1224. var id = this.warese_out_id;
  1225. console.log("采购单ID",id)
  1226. var warehousing_id = this.id
  1227. console.log("采购订单ID",warehousing_id)
  1228. var params = {
  1229. id: id,
  1230. warehousing_id:warehousing_id,
  1231. };
  1232. MofyGoodOrder(params).then((response) => {
  1233. if (response.data.state == 1) {
  1234. var msg = response.data.data.msg;
  1235. if (msg == 1) {
  1236. this.$message.success("反审核成功!");
  1237. this.is_check = 2
  1238. this.disabled = false
  1239. this.Reviewed = false
  1240. }
  1241. if (msg == 2) {
  1242. var cancelList = response.data.data.cancelList
  1243. console.log("cancelLIST2332322332232323",cancelList)
  1244. this.orderList = cancelList
  1245. this.$refs.Popup.dialogVisible = true
  1246. return
  1247. }
  1248. var purcaseOrder = response.data.data.purcaseOrder;
  1249. console.log("采购订单", purcaseOrder);
  1250. var goodOrder = response.data.data.goodOrder;
  1251. console.log("采购单", goodOrder);
  1252. var drugList = response.data.data.drugList;
  1253. console.log("druglist23323223", drugList);
  1254. var ids = "";
  1255. // 如果采购单没有数据,则代表改订单第一次生成采购订单数据,未入库
  1256. if (goodOrder.length == 0) {
  1257. var is_warehouse = 2;
  1258. this.ModefySupplyWarehousing(is_warehouse, this.id);
  1259. return
  1260. }
  1261. for (let i = 0; i < purcaseOrder.length; i++) {
  1262. for (let j = 0; j < drugList.length; j++) {
  1263. if (purcaseOrder[i].is_source == 1) {
  1264. if (purcaseOrder[i].supply_unit == drugList[j].max_unit) {
  1265. purcaseOrder[i].count = purcaseOrder[i].count * drugList[j].min_number;
  1266. }
  1267. }
  1268. }
  1269. }
  1270. for (let i = 0; i < goodOrder.length; i++) {
  1271. for (let j = 0; j < drugList.length; j++) {
  1272. if (goodOrder[i].is_source == 1) {
  1273. if (goodOrder[i].supply_unit == drugList[j].max_unit) {
  1274. goodOrder[i].count = goodOrder[i].count * drugList[j].min_number;
  1275. }
  1276. }
  1277. }
  1278. }
  1279. let objInfo = {};
  1280. if (goodOrder.length > 0) {
  1281. goodOrder.forEach((item, index) => {
  1282. let { project_id } = item;
  1283. if (!objInfo[project_id]) {
  1284. objInfo[project_id] = {
  1285. project_id,
  1286. child: [],
  1287. count: 0,
  1288. };
  1289. }
  1290. });
  1291. let newArr = Object.values(objInfo);
  1292. for (let i = 0; i < goodOrder.length; i++) {
  1293. for (let j = 0; j < newArr.length; j++) {
  1294. if (goodOrder[i].project_id == newArr[j].project_id) {
  1295. newArr[j].child.push(goodOrder[i]);
  1296. }
  1297. }
  1298. }
  1299. console.log("newAr2332232323", newArr);
  1300. for (let i = 0; i < newArr.length; i++) {
  1301. for (let j = 0; j < newArr[i].child.length; j++) {
  1302. newArr[i].count += newArr[i].child[j].count;
  1303. }
  1304. }
  1305. var arr = [];
  1306. var total = 0;
  1307. var str = "";
  1308. //如果采购单有数据,则需要比较数量
  1309. if (newArr.length > 0) {
  1310. for (let i = 0; i < purcaseOrder.length; i++) {
  1311. for (let j = 0; j < newArr.length; j++) {
  1312. if (purcaseOrder[i].project_id == newArr[j].project_id) {
  1313. //根据商品ID比较数量大小,如果采购单的数量大于采购订单的数据
  1314. if (purcaseOrder[i].count < newArr[j].count) {
  1315. arr.push(purcaseOrder[i].project_id);
  1316. }
  1317. }
  1318. }
  1319. }
  1320. console.log("arr233232233232",arr)
  1321. if (arr.length == 0) {
  1322. //未入库
  1323. var is_warehouse = 2;
  1324. this.ModefySupplyWarehousing(is_warehouse, this.id);
  1325. }
  1326. if (arr.length > 0) {
  1327. //部分入库
  1328. var is_warehouse = 3;
  1329. this.ModefySupplyWarehousing(is_warehouse, this.id);
  1330. }
  1331. }
  1332. }
  1333. }
  1334. });
  1335. },
  1336. UpdateSupplyWahouseingInfo() {
  1337. var params = {
  1338. warehousing_id: this.warehousing_id,
  1339. };
  1340. console.log("采购单ID",params)
  1341. UpdateSupplyWahouseingInfo(params).then((response) => {
  1342. if (response.data.state == 1) {
  1343. var msg = response.data.data.msg;
  1344. }
  1345. });
  1346. },
  1347. toClick() {
  1348. //先判断采购单号有没有关联的采购退货单号,如果没有,则为首次生成采购退货单
  1349. if (this.is_check == 2) {
  1350. this.$message.error("该采购单未审核,不能生成退货单数据!");
  1351. return false;
  1352. }
  1353. var id = this.warese_out_id;
  1354. console.log("生成采购单ID22323",id)
  1355. getSupplyWarehouseOutById(id).then((response) => {
  1356. if (response.data.state == 1) {
  1357. var cancelList = response.data.data.cancelList;
  1358. console.log("退库单", cancelList);
  1359. var drugList = response.data.data.drugList;
  1360. console.log("药品列表", drugList);
  1361. var cancelOrderList = response.data.data.cancelOrderList;
  1362. console.log("退库单详情", cancelOrderList);
  1363. var ids =""
  1364. if(cancelList.length == 0){
  1365. this.$router.push({ path: "/good/return/add?id=" +id+"&ids="+ids });
  1366. }
  1367. if (cancelList.length > 0) {
  1368. var outList = response.data.data.outList;
  1369. console.log("购货单2322323",outList)
  1370. for(let i=0;i<outList.length;i++){
  1371. if(outList[i].is_source == 1){
  1372. for(let j=0;j<drugList.length;j++){
  1373. if(outList[i].project_id == drugList[j].id){
  1374. if(outList[i].supply_unit == drugList[j].max_unit){
  1375. outList[i].count = outList[i].count * drugList[j].min_number
  1376. }
  1377. }
  1378. }
  1379. }
  1380. }
  1381. for(let i=0;i<cancelOrderList.length;i++){
  1382. if(cancelOrderList[i].is_source == 1){
  1383. for(let j=0;j<drugList.length;j++){
  1384. if(cancelOrderList[i].project_id == drugList[j].id){
  1385. if(cancelOrderList[i].supply_unit == drugList[j].max_unit){
  1386. cancelOrderList[i].count = cancelOrderList[i].count * drugList[j].min_number
  1387. }
  1388. }
  1389. }
  1390. }
  1391. }
  1392. let objInfo = {};
  1393. if(cancelOrderList.length >0){
  1394. cancelOrderList.forEach((item, index) => {
  1395. let { project_id } = item;
  1396. if (!objInfo[project_id]) {
  1397. objInfo[project_id] = {
  1398. project_id,
  1399. child: [],
  1400. count: 0,
  1401. };
  1402. }
  1403. });
  1404. let newArr = Object.values(objInfo)
  1405. for (let i = 0; i < cancelOrderList.length; i++) {
  1406. for (let j = 0; j < newArr.length; j++) {
  1407. if (cancelOrderList[i].project_id == newArr[j].project_id) {
  1408. newArr[j].child.push(cancelOrderList[i])
  1409. }
  1410. }
  1411. }
  1412. for (let i = 0; i < newArr.length; i++) {
  1413. for (let j = 0; j < newArr[i].child.length; j++) {
  1414. newArr[i].count += newArr[i].child[j].count;
  1415. }
  1416. }
  1417. var arr = []
  1418. var total = 0;
  1419. var str = "";
  1420. //如果采购单有数据,则需要比较数量
  1421. if (newArr.length > 0) {
  1422. for (let i = 0; i < outList.length; i++) {
  1423. for (let j = 0; j < newArr.length; j++) {
  1424. if (outList[i].project_id == newArr[j].project_id) {
  1425. //根据商品ID比较数量大小,把数量不足的商品ID储存,表示退货单的数量未满足采购单的数据,可以继续生成退货单
  1426. if (outList[i].count > newArr[j].count) {
  1427. arr.push(outList[i].project_id);
  1428. }
  1429. }
  1430. }
  1431. }
  1432. //如果total的长度等于 采购单的长度,怎表示该采购订单已经全部生成
  1433. if (arr.length == 0) {
  1434. this.$message.error("该订单已全部生成退库单,请知悉!");
  1435. return
  1436. }
  1437. console.log("arr23323232232323",arr)
  1438. if (arr.length > 0) {
  1439. str = arr.join(",");
  1440. this.$router.push({ path: "/good/return/edit?id=" + id + "&ids=" + str});
  1441. }
  1442. }
  1443. }
  1444. }
  1445. }
  1446. });
  1447. },
  1448. },
  1449. created() {
  1450. const tempObj = {};
  1451. tempObj["id"] = 0;
  1452. tempObj["name"] = "";
  1453. tempObj["supply_name"] = "";
  1454. tempObj["supply_type"] = "";
  1455. tempObj["supply_specification_name"] = "";
  1456. tempObj["supply_total"] = "";
  1457. tempObj["supply_count"] = "";
  1458. tempObj["supply_price"] = "";
  1459. tempObj["supply_total_price"] = "";
  1460. tempObj["supply_manufacturer"] = "";
  1461. tempObj["supply_license_number"] = "";
  1462. tempObj["supply_remake"] = "";
  1463. tempObj["type"] = 0;
  1464. tempObj["is_total"] = 1;
  1465. tempObj["project_id"] = 0;
  1466. tempObj["supply_unit"] = "";
  1467. tempObj["supply_batch_number"] = "";
  1468. tempObj["supply_product_date"] = "";
  1469. tempObj["order_number"] = "";
  1470. tempObj["supply_expiry_date"] = "";
  1471. tempObj["manufacturer_id"] = "";
  1472. tempObj["min_price"] = ""
  1473. tempObj["warehouse_info_id"] = 0
  1474. tempObj["warehousing_id"] = 0
  1475. this.recordInfo.tableList.push(tempObj);
  1476. this.getInitOrder();
  1477. if (parseInt(this.$route.query.id) > 0) {
  1478. this.getPurchaseOrderDetail();
  1479. }
  1480. this.start_time = this.getTimes(new Date());
  1481. this.end_time = this.getTimes(new Date());
  1482. },
  1483. };
  1484. </script>
  1485. <style rel="stylesheet/css" lang="scss" scoped>
  1486. /deep/ .el-table__body-wrapper::-webkit-scrollbar {
  1487. width: 10px;
  1488. height: 10px;
  1489. }
  1490. .information {
  1491. border: 1px #dcdfe6 solid;
  1492. padding: 30px 20px 30px 20px;
  1493. .border {
  1494. border-bottom: 1px #dcdfe6 solid;
  1495. margin: 0px 0 20px 0;
  1496. }
  1497. }
  1498. .title {
  1499. background: #409eff;
  1500. height: 44px;
  1501. line-height: 44px;
  1502. padding: 0 0 0 10px;
  1503. color: #fff;
  1504. margin: 0 0 10px 0;
  1505. }
  1506. .edit_separater {
  1507. border-top: 1px solid rgb(233, 233, 233);
  1508. margin-top: 15px;
  1509. margin-bottom: 15px;
  1510. }
  1511. </style>
  1512. <style>
  1513. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  1514. font-size: 12px;
  1515. }
  1516. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  1517. background: #6fb5fa;
  1518. }
  1519. .count {
  1520. color: #bd2c00;
  1521. }
  1522. .el-table td,
  1523. .el-table th.is-leaf,
  1524. .el-table--border,
  1525. .el-table--group {
  1526. border-color: #d0d3da;
  1527. }
  1528. .el-table--border::after,
  1529. .el-table--group::after,
  1530. .el-table::before {
  1531. background-color: #d0d3da;
  1532. }
  1533. .el-table__fixed-right {
  1534. width: 150px;
  1535. bottom: 20px;
  1536. height: 100%;
  1537. }
  1538. </style>