addGoodOrder.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  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 style="justify-content: space-between;margin: 0px 0 12px 0;display: flex;align-items: center;">
  8. <div>
  9. <span style="color:red">*</span><span>供应商:</span>
  10. <el-select v-model="supplier_name" style="width:140px;margin-right:10px;" placeholder="请选择">
  11. <el-option
  12. v-for="item in supplyList"
  13. :key="item.id"
  14. :label="item.supplier_name"
  15. :value="item.id">
  16. </el-option>
  17. </el-select>
  18. <span>单据日期:</span>
  19. <el-date-picker
  20. size="small"
  21. v-model="start_time"
  22. prefix-icon="el-icon-date"
  23. :editable="false"
  24. style="width: 196px;"
  25. type="date"
  26. placeholder="选择日期时间"
  27. align="right"
  28. format="yyyy-MM-dd"
  29. value-format="yyyy-MM-dd"
  30. ></el-date-picker>
  31. <!-- <span>交货日期:</span> -->
  32. <!-- <el-date-picker
  33. size="small"
  34. v-model="end_time"
  35. prefix-icon="el-icon-date"
  36. :editable="false"
  37. style="width: 196px;"
  38. type="date"
  39. placeholder="选择日期时间"
  40. align="right"
  41. format="yyyy-MM-dd"
  42. value-format="yyyy-MM-dd"
  43. @change="endTimeChange"
  44. ></el-date-picker> -->
  45. <span>单据编码:{{good_number}}</span>
  46. </div>
  47. <div>
  48. <el-button size="small" type="primary" @click="saveGoodOrder" v-show="showOne">保存</el-button>
  49. <el-button size="small" type="primary" @click="updateGoodOrder" v-show="showTwo">保存</el-button>
  50. <el-button size="small" type="primary" @click="checkPurchaseOrder">审核</el-button>
  51. </div>
  52. </div>
  53. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  54. <el-table
  55. :row-style="{ color: '#303133' }"
  56. :header-cell-style="{
  57. backgroundColor: 'rgb(245, 247, 250)',
  58. color: '#606266'
  59. }"
  60. :data="recordInfo.tableList"
  61. :class="signAndWeighBoxPatients"
  62. border
  63. style="width: 100%"
  64. max-height="450"
  65. >
  66. <el-table-column align="center" width="200px">
  67. <template slot="header" slot-scope="scope">
  68. <span>商品<span style="color: red">*</span></span>
  69. </template>
  70. <template slot-scope="scope">
  71. <el-form-item :prop="'tableList.' + scope.$index + '.name'" :rules='tableRules.name'>
  72. <el-select v-model="scope.row.name" style="width:160px;" filterable placeholder="请选择商品" @change="changeName" @input="changeGoodName(scope.$index)" :disabled="disabled">
  73. <el-option
  74. v-for="(item,index) in tabList"
  75. :key="index"
  76. :label="item.supply_name"
  77. :value="item">
  78. </el-option>
  79. </el-select>
  80. </el-form-item>
  81. </template>
  82. </el-table-column>
  83. <el-table-column align="center" width="150px">
  84. <template slot="header" slot-scope="scope">
  85. <span>商品类别</span>
  86. </template>
  87. <template slot-scope="scope">
  88. <el-input v-model="scope.row.supply_type" style="width:120px" :disabled="true" placeholder="商品类别"></el-input>
  89. <div style="visibility: hidden">/</div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="规格&单位" align="center" width="150px">
  93. <template slot-scope="scope">
  94. <el-input v-model="scope.row.supply_specification_name" style="width:120px" :disabled="true" placeholder="规格&单位"></el-input>
  95. <div style="visibility: hidden">/</div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column label="单位" align="center" width="120px">
  99. <template slot="header" slot-scope="scope">
  100. <span>单位<span style="color: red">*</span></span>
  101. </template>
  102. <template slot-scope="scope">
  103. <el-form-item :prop="'tableList.' + scope.$index + '.supply_unit'" :rules='tableRules.supply_unit'>
  104. <el-select v-model="scope.row.supply_unit" style="width:100px;" filterable placeholder="请选择" :disabled="disabled">
  105. <el-option
  106. v-for="(item,index) in scope.row.unitList"
  107. :key="index"
  108. :label="item.name"
  109. :value="item.name">
  110. </el-option>
  111. </el-select>
  112. </el-form-item>
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="批号" align="center" width="200px">
  116. <template slot="header" slot-scope="scope">
  117. <span>批号<span style="color: red">*</span></span>
  118. </template>
  119. <template slot-scope="scope">
  120. <el-form-item :prop="'tableList.' + scope.$index + '.supply_batch_number'" :rules='tableRules.supply_batch_number'>
  121. <el-input v-model="scope.row.supply_batch_number" style="width:180px" :disabled="disabled" placeholder="请输入批号"></el-input>
  122. </el-form-item>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="有效日期" align="center" width="200px">
  126. <template slot="header" slot-scope="scope">
  127. <span>有效日期<span style="color: red">*</span></span>
  128. </template>
  129. <template slot-scope="scope">
  130. <el-form-item :prop="'tableList.' + scope.$index + '.supply_expiry_date'"
  131. :rules="tableRules.supply_expiry_date">
  132. <el-date-picker prefix-icon="el-icon-date" style="width:180px" v-model="scope.row.supply_expiry_date"
  133. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  134. value-format="yyyy-MM-dd">
  135. </el-date-picker>
  136. </el-form-item>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="可用库存" align="center" width="150px">
  140. <template slot-scope="scope">
  141. <el-input v-model="scope.row.supply_total" style="width:100px" :disabled="true"></el-input>
  142. <div style="visibility: hidden">/</div>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="数量" align="center" width="140px">
  146. <template slot="header" slot-scope="scope">
  147. <span>数量<span style="color: red">*</span></span>
  148. </template>
  149. <template slot-scope="scope">
  150. <el-form-item :prop="'tableList.' + scope.$index + '.supply_count'" :rules='tableRules.supply_count'>
  151. <el-input v-model="scope.row.supply_count" style="width:100px" :disabled="disabled" placeholder="请输入数量"></el-input>
  152. </el-form-item>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="采购单价" align="center" width="180px">
  156. <template slot-scope="scope">
  157. <el-input v-model="scope.row.supply_price" style="width:140px" :disabled="disabled" placeholder="请输入采购单价"></el-input>
  158. <div style="visibility: hidden">/</div>
  159. </template>
  160. </el-table-column>
  161. <el-table-column label="采购金额" align="center" width="120px">
  162. <template slot-scope="scope">
  163. {{calculate(scope.row.supply_count * scope.row.supply_price)}}
  164. </template>
  165. </el-table-column>
  166. <el-table-column label="生产日期" align="center" width="200px">
  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 :prop="'tableList.' + scope.$index + '.supply_product_date'"
  172. :rules="tableRules.supply_product_date">
  173. <el-date-picker prefix-icon="el-icon-date" style="width: 180px" v-model="scope.row.supply_product_date"
  174. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  175. value-format="yyyy-MM-dd">
  176. </el-date-picker>
  177. </el-form-item>
  178. </template>
  179. </el-table-column>
  180. <el-table-column label="生产厂家" align="center" width="200px">
  181. <template slot-scope="scope">
  182. <el-select size="small" v-model="scope.row.supply_manufacturer" filterable :disabled="true">
  183. <el-option
  184. v-for="(option, index) in manufactuerList"
  185. :key="index"
  186. :label="option.manufacturer_name"
  187. :value="option.id">
  188. </el-option>
  189. </el-select>
  190. <div style="visibility: hidden">/</div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column label="批准文号" align="center" width="200px">
  194. <template slot-scope="scope">
  195. <el-input v-model="scope.row.supply_license_number" style="width:160px" :disabled="true"></el-input>
  196. <div style="visibility: hidden">/</div>
  197. </template>
  198. </el-table-column>
  199. <el-table-column label="关联采购订单号" align="center" width="200px">
  200. <template slot-scope="scope">
  201. <el-input v-model="scope.row.order_number" style="width:160px" :disabled="true"></el-input>
  202. <div style="visibility: hidden">/</div>
  203. </template>
  204. </el-table-column>
  205. <el-table-column label="备注" align="center" width="200px">
  206. <template slot-scope="scope">
  207. <el-input v-model="scope.row.supply_remake" style="width:160px" :disabled="disabled" placeholder="请输入备注"></el-input>
  208. <div style="visibility: hidden">/</div>
  209. </template>
  210. </el-table-column>
  211. <el-table-column label="操作" align="center" width="150px" fixed="right" >
  212. <template slot-scope="scope">
  213. <el-tooltip class="item" effect="dark" content="新增" placement="top" >
  214. <el-button
  215. size="mini"
  216. type="primary"
  217. icon="el-icon-circle-plus-outline"
  218. @click="handleEdit(scope.$index, scope.row)">
  219. </el-button>
  220. </el-tooltip>
  221. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  222. <el-button
  223. size="mini"
  224. type="danger"
  225. icon="el-icon-delete"
  226. @click="handleDelete(scope.$index, scope.row)">
  227. </el-button>
  228. </el-tooltip>
  229. </template>
  230. </el-table-column>
  231. </el-table>
  232. <div style="margin-top: 10px">
  233. <el-input
  234. type="textarea"
  235. :rows="2"
  236. placeholder="备注信息"
  237. v-model="return_remark"
  238. >
  239. </el-input>
  240. </div>
  241. </el-form>
  242. <div style="margin-top:10px">
  243. 合计:{{getAllPrice()}} 元
  244. </div>
  245. <div style="margin-top:10px">
  246. <span>优惠率:<el-input style="width:150px" v-model="rate_of_concession" placeholder="请输入优惠率"></el-input>%</span>
  247. <span>优惠金额:<el-input style="width:150px" v-model="discount_amount" placeholder="请输入优惠金额"></el-input></span>
  248. <span>本次付款:<el-input style="width:150px" v-model="payment" placeholder="请输入本次付款"></el-input></span>
  249. <span>本次欠款:<el-input style="width:150px" v-model="arrearage" placeholder="请输入本次欠款"></el-input></span>
  250. </div>
  251. </div>
  252. <!-- <el-dialog
  253. title="提示"
  254. :visible.sync="dialogVisible"
  255. width="30%"
  256. :before-close="handleClose">
  257. <span>这是一段信息</span>
  258. <span slot="footer" class="dialog-footer">
  259. <el-button @click="dialogVisible = false">取 消</el-button>
  260. <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  261. </span>
  262. </el-dialog> -->
  263. </div>
  264. </template>
  265. <script>
  266. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  267. import {uParseTime } from '@/utils/tools'
  268. import {getInitOrder,checkPurchaseOrder,getPurchaseOrderInfo,addGoodOrder,updateGoodOrder} from "@/api/supply"
  269. export default {
  270. name: "addPurchaseOrder",
  271. components: {
  272. BreadCrumb
  273. },
  274. data() {
  275. return {
  276. crumbs: [
  277. { path: false, name: "采购单" },
  278. { path: "/supply/good/order/query", name: "新增采购单" }
  279. ],
  280. showTwo:true,
  281. showOne:false,
  282. recordInfo: {
  283. tableList:[],
  284. },
  285. keywords: "",
  286. total: 0,
  287. multipleSelection: [],
  288. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  289. start_time: "",
  290. end_time: "",
  291. page: 1,
  292. limit: 10,
  293. goodType: [],
  294. goodInfo: [],
  295. org_id:0,
  296. types:[],
  297. tyep_name:"",
  298. form:{
  299. manufacturer_id:"",
  300. },
  301. tabList:[],
  302. manufactuerList:[],
  303. currentIndex: 0,
  304. goodTypeList:[],
  305. drugTypeList:[],
  306. supplier_name:"",
  307. supplyList:[],
  308. rate_of_concession:"",
  309. discount_amount:"",
  310. start_time:"",
  311. end_time:"",
  312. tableRules: {
  313. name: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
  314. supply_count: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
  315. supply_batch_number:[{required:true,message:"批号不能为空", trigger: 'blur'}],
  316. supply_product_date:[{required:true,message:"生产日期不能为空", trigger: 'blur'}],
  317. supply_expiry_date:[{required:true,message:"有效日期不能为空",trigger: 'blur'}]
  318. },
  319. warehousing_id:0,
  320. number:"",
  321. loading:false,
  322. drugList:[],
  323. goodList:[],
  324. id:0,
  325. disabled:false,
  326. is_check:0,
  327. dialogVisible:false,
  328. arrearage:"",
  329. payment:"",
  330. good_number:"",
  331. orderInfo:[],
  332. showOne:true,
  333. showTwo:false,
  334. warese_out_id:0,
  335. return_remark:"",
  336. };
  337. },
  338. methods:{
  339. getInitOrder(){
  340. getInitOrder().then(response=>{
  341. if(response.data.state == 1){
  342. var drugList = response.data.data.drugList
  343. this.manufactuerList = response.data.data.manufactuerList
  344. this.goodTypeList = response.data.data.goodTypeList
  345. this.drugTypeList = response.data.data.drugTypeList
  346. this.supplyList = response.data.data.supplyList
  347. for(let i=0;i<drugList.length;i++){
  348. for(let z=0;z<drugList[i].drug_warehouse_info.length;z++){
  349. if(drugList[i].max_unit == drugList[i].drug_warehouse_info[z].max_unit){
  350. drugList[i].drug_warehouse_info[z].stock_max_number = drugList[i].drug_warehouse_info[z].stock_max_number * drugList[i].min_number
  351. }
  352. }
  353. for(let j=0;j<this.manufactuerList.length;j++){
  354. if(drugList[i].manufacturer == this.manufactuerList[j].id){
  355. drugList[i].manufacturer = this.manufactuerList[j].manufacturer_name
  356. }
  357. }
  358. for(let y=0;y<this.drugTypeList.length;y++){
  359. if(drugList[i].drug_type == this.drugTypeList[y].value){
  360. drugList[i].drug_type = this.drugTypeList[y].name
  361. }
  362. }
  363. drugList[i].supply_name = drugList[i].drug_name + " " + drugList[i].dose +drugList[i].dose_unit+"*"+drugList[i].min_number+ drugList[i].min_unit+"/"+drugList[i].max_unit + " " + drugList[i].manufacturer
  364. drugList[i].supply_type = drugList[i].drug_type
  365. drugList[i].supply_specification_name = drugList[i].dose +drugList[i].dose_unit+"*"+drugList[i].min_number+ drugList[i].min_unit+"/"+drugList[i].max_unit
  366. drugList[i].supply_total = this.getWarehoseInfo(drugList[i].drug_warehouse_info,drugList[i].max_unit,drugList[i].min_unit,drugList[i].min_number)
  367. drugList[i].supply_count = ""
  368. drugList[i].supply_total_price = ""
  369. drugList[i].supply_manufacturer= drugList[i].manufacturer
  370. drugList[i].supply_license_number= drugList[i].number
  371. drugList[i].supply_remake = ""
  372. drugList[i].type = 1
  373. drugList[i].supply_price = drugList[i].last_price
  374. drugList[i].name = drugList[i].drug_name
  375. if(drugList[i].max_unit != drugList[i].min_unit){
  376. drugList[i].unitList = [{id:1,name:""},{id:2,name:""}]
  377. }
  378. if(drugList[i].max_unit == drugList[i].min_unit){
  379. drugList[i].unitList = [{id:1,name:""}]
  380. }
  381. drugList[i].supply_unit = drugList[i].max_unit
  382. for(let j=0;j<drugList[i].unitList.length;j++){
  383. if(drugList[i].max_unit != drugList[i].min_unit){
  384. drugList[i].unitList[0].name = drugList[i].max_unit
  385. drugList[i].unitList[1].name = drugList[i].min_unit
  386. }
  387. if(drugList[i].max_unit == drugList[i].min_unit){
  388. drugList[i].unitList[0].name = drugList[i].max_unit
  389. }
  390. }
  391. this.tabList.push(drugList[i])
  392. }
  393. this.drugList = drugList
  394. var goodList = response.data.data.goodList
  395. for(let i=0;i<goodList.length;i++){
  396. for(let j=0;j<this.manufactuerList.length;j++){
  397. if(goodList[i].manufacturer == this.manufactuerList[j].id){
  398. goodList[i].manufacturer = this.manufactuerList[j].manufacturer_name
  399. }
  400. }
  401. for(let y=0;y<this.goodTypeList.length;y++){
  402. if(goodList[i].good_type_id == this.goodTypeList[y].id){
  403. goodList[i].good_type_id = this.goodTypeList[y].type_name
  404. }
  405. }
  406. goodList[i].supply_name = goodList[i].good_name + " " + goodList[i].specification_name + " " +goodList[i].manufacturer
  407. goodList[i].supply_type = goodList[i].good_type_id
  408. goodList[i].supply_specification_name =goodList[i].specification_name
  409. goodList[i].supply_price = goodList[i].buy_price
  410. goodList[i].supply_total = this.getTotalStockCount(goodList[i].good_warehouse_info)
  411. goodList[i].supply_count = ""
  412. goodList[i].supply_total_price = ""
  413. goodList[i].supply_manufacturer = goodList[i].manufacturer
  414. goodList[i].supply_license_number = ""
  415. goodList[i].supply_remake = ""
  416. goodList[i].type = 2
  417. goodList[i].name = goodList[i].good_name
  418. goodList[i].unitList = [{id:1,name:""}]
  419. goodList[i].supply_unit = goodList[i].packing_unit
  420. for(let j=0;j<goodList[i].unitList.length;j++){
  421. goodList[i].unitList[0].name = goodList[i].packing_unit
  422. }
  423. this.tabList.push(goodList[i])
  424. }
  425. this.goodList = goodList
  426. }
  427. })
  428. },
  429. changeGoodName(val){
  430. this.currentIndex = val
  431. },
  432. changeName(val){
  433. for(let i=0;i<this.recordInfo.tableList.length;i++){
  434. if(this.currentIndex == i){
  435. this.recordInfo.tableList[i].project_id = val.id
  436. this.recordInfo.tableList[i].type = val.type
  437. this.recordInfo.tableList[i].name = val.name
  438. this.recordInfo.tableList[i].supply_name = val.supply_name
  439. this.recordInfo.tableList[i].supply_type = val.supply_type
  440. this.recordInfo.tableList[i].supply_specification_name = val.supply_specification_name
  441. this.recordInfo.tableList[i].supply_total = val.supply_total
  442. if(val.supply_count == NaN){
  443. this.recordInfo.tableList[i].supply_count = ""
  444. }else{
  445. this.recordInfo.tableList[i].supply_count = val.supply_count?val.supply_count:""
  446. }
  447. this.recordInfo.tableList[i].supply_price = val.supply_price?val.supply_price:""
  448. this.recordInfo.tableList[i].supply_total_price = (val.supply_count * val.supply_price).toFixed(2)
  449. this.recordInfo.tableList[i].supply_manufacturer = val.supply_manufacturer
  450. this.recordInfo.tableList[i].supply_license_number = val.supply_license_number
  451. this.recordInfo.tableList[i].supply_remake = val.supply_remake
  452. this.recordInfo.tableList[i].is_total = val.is_total
  453. this.recordInfo.tableList[i].supply_unit = val.supply_unit
  454. this.recordInfo.tableList[i].unitList = val.unitList
  455. }
  456. }
  457. },
  458. handleEdit(){
  459. const tempObj = {}
  460. tempObj["id"] = 0
  461. tempObj["name"] = ""
  462. tempObj['supply_name'] = ""
  463. tempObj['supply_type'] = ""
  464. tempObj['supply_specification_name'] = ''
  465. tempObj['supply_total'] = ""
  466. tempObj['supply_count'] = ""
  467. tempObj['supply_price'] = ""
  468. tempObj['supply_total_price'] = ""
  469. tempObj['supply_manufacturer'] = ''
  470. tempObj['supply_license_number'] = ''
  471. tempObj['supply_remake'] = ''
  472. tempObj['type'] = 0
  473. tempObj['is_total'] = 1
  474. tempObj["project_id"] = 0
  475. tempObj["supply_unit"] = ""
  476. tempObj["supply_batch_number"] = ""
  477. tempObj["supply_product_date"] = ""
  478. tempObj["order_number"] = ""
  479. tempObj["supply_expiry_date"] = ""
  480. tempObj["manufacturer_id"] = ""
  481. this.recordInfo.tableList.push(tempObj)
  482. },
  483. handleDelete: function(index, row) {
  484. if (this.recordInfo.tableList.length <= 1) {
  485. this.$message.error('只有一条记录的时候无法删除')
  486. return
  487. } else {
  488. this.recordInfo.tableList.splice(index, 1)
  489. }
  490. },
  491. getWarehoseInfo(arr,max_unit,min_unit,min_number){
  492. var total = 0
  493. var max_str= ""
  494. var min_str = ""
  495. if (arr.length > 0) {
  496. for(let i=0;i<arr.length;i++){
  497. total += parseInt(arr[i].stock_max_number+arr[i].stock_min_number)
  498. }
  499. }
  500. if (total < min_number){
  501. min_str = total + min_unit
  502. }
  503. if (total == 0) {
  504. min_str = ""
  505. max_str = ""
  506. }
  507. if (total >=min_number) {
  508. if(parseInt(total/min_number)!=0){
  509. max_str = parseInt(total/min_number) + max_unit
  510. }
  511. if(total%min_number!=0){
  512. min_str = total%min_number + min_unit
  513. }
  514. }
  515. return max_str + min_str
  516. },
  517. getTotalStockCount(arr){
  518. var total_count = 0
  519. for(let i=0;i<arr.length;i++){
  520. total_count += arr[i].stock_count
  521. }
  522. return total_count
  523. },
  524. calculate: function(val) {
  525. if (isNaN(val)) {
  526. return "";
  527. }
  528. if (val == 0) {
  529. return "";
  530. }
  531. return Math.round(parseFloat(val) * 100) / 100;
  532. },
  533. getTimes(time) {
  534. if (time === '') {
  535. return ''
  536. }
  537. return uParseTime(time, '{y}-{m}-{d}')
  538. },
  539. getAllPrice(){
  540. var total_price = 0
  541. for(let i=0;i<this.recordInfo.tableList.length;i++){
  542. total_price += (this.recordInfo.tableList[i].supply_price * this.recordInfo.tableList[i].supply_count)
  543. }
  544. return total_price.toFixed(2)
  545. },
  546. checkPurchaseOrder(id,index){
  547. this.$confirm('是否审核?', {
  548. confirmButtonText: '确 定',
  549. cancelButtonText: '取 消',
  550. type: 'warning'
  551. }).then(() => {
  552. checkPurchaseOrder(this.id).then(response => {
  553. if (response.data.state == 1) {
  554. var info = response.data.data.info
  555. this.disabled = true
  556. this.$message.success("审核成功!")
  557. this.getPurchaseOrderDetail()
  558. }
  559. })
  560. })
  561. .catch(() => {
  562. })
  563. },
  564. getPurchaseOrderDetail(){
  565. var id = this.$route.query.id
  566. var ids = this.$route.query.ids
  567. getPurchaseOrderInfo(id,ids).then(response=>{
  568. if(response.data.state == 1){
  569. var info = response.data.data.info
  570. this.is_check = info.is_check
  571. this.id = info.id
  572. this.supplier_name = info.supplier_id
  573. this.rate_of_concession = info.rate_of_concession
  574. this.discount_amount = info.discount_amount
  575. this.number = info.number
  576. var orderInfo = response.data.data.orderInfo
  577. for(let i=0;i<orderInfo.length;i++){
  578. orderInfo[i].supply_batch_number = ""
  579. orderInfo[i].supply_product_date = ""
  580. orderInfo[i].supply_expiry_date = ""
  581. }
  582. console.log("drugli323322332", orderInfo)
  583. var drugList = response.data.data.baseList
  584. var goodList = response.data.data.goodList
  585. for(let i=0;i< orderInfo.length;i++){
  586. orderInfo[i].supply_count = orderInfo[i].count
  587. orderInfo[i].supply_price = orderInfo[i].price
  588. orderInfo[i].supply_remake = orderInfo[i].remark
  589. orderInfo[i].type = orderInfo[i].is_source
  590. orderInfo[i].project_id = orderInfo[i].project_id
  591. orderInfo[i].supply_unit = orderInfo[i].supply_unit
  592. orderInfo[i].order_number = orderInfo[i].order_number
  593. orderInfo[i].supply_total_price = (orderInfo[i].count * orderInfo[i].price).toFixed(2)
  594. if(orderInfo[i].is_source == 1){
  595. for(let j=0;j<drugList.length;j++){
  596. if( orderInfo[i].project_id == drugList[j].id){
  597. if(drugList[j].max_unit!=drugList[j].min_unit){
  598. orderInfo[i].unitList = [{id:1,name:""},{id:2,name:""}]
  599. orderInfo[i].unitList[0].name = drugList[j].max_unit
  600. orderInfo[i].unitList[1].name = drugList[j].min_unit
  601. }
  602. if(drugList[j].max_unit == drugList[j].min_unit){
  603. orderInfo[i].unitList = [{id:1,name:""}]
  604. orderInfo[i].unitList[0].name = drugList[j].max_unit
  605. }
  606. }
  607. }
  608. }
  609. if(orderInfo[i].is_source == 2){
  610. for(let j=0;j<goodList.length;j++){
  611. if(orderInfo[i].project_id == goodList[j].id){
  612. orderInfo[i].unitList = [{id:1,name:""}]
  613. orderInfo[i].unitList[0].name = goodList[j].packing_unit
  614. }
  615. }
  616. }
  617. }
  618. this.recordInfo.tableList= []
  619. this.recordInfo.tableList = orderInfo
  620. console.log("orderINFO23323232",this.recordInfo.tableList)
  621. }
  622. })
  623. },
  624. toPrint(){
  625. var id = this.$route.query.id
  626. this.$router.push({path:"/purchase/order/print?&id="+id})
  627. },
  628. saveGoodOrder(){
  629. if(this.supplier_name == 0 || this.supplier_name == ""){
  630. this.$message.error("供应商不能为空!")
  631. this.loading = false
  632. return false
  633. }
  634. for(let i=0;i<this.recordInfo.tableList.length;i++){
  635. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count)
  636. this.recordInfo.tableList[i].supply_price = this.recordInfo.tableList[i].supply_price.toString()
  637. this.recordInfo.tableList[i].supply_total_price= this.recordInfo.tableList[i].supply_total_price.toString()
  638. this.recordInfo.tableList[i].supply_total = this.recordInfo.tableList[i].supply_total.toString()
  639. for(let j=0;j<this.manufactuerList.length;j++){
  640. if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name){
  641. this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id
  642. }
  643. if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].id){
  644. this.recordInfo.tableList[i].supply_manufacturer = this.manufactuerList[j].manufacturer_name
  645. }
  646. }
  647. }
  648. var start = this.start_time
  649. this.$refs["tableForm"].validate((valid)=>{
  650. if(valid){
  651. this.loading = true
  652. var warehousing_id = this.$route.query.id
  653. var params = {
  654. stockIn:this.recordInfo.tableList,
  655. return_remake:this.return_remark,
  656. }
  657. console.log("stockIN2323322332322323",params)
  658. addGoodOrder(params,this.supplier_name,start,this.arrearage,this.payment,warehousing_id,this.number,this.rate_of_concession,this.discount_amount).then(response=>{
  659. if(response.data.state == 1){
  660. this.loading = false
  661. this.$message.success("保存成功!")
  662. this.showOne = false
  663. this.showTwo = true
  664. var orderInfo = response.data.data.list
  665. var warehouseOut = response.data.data.warehouseOut
  666. this.warese_out_id = warehouseOut.id
  667. this.good_number = warehouseOut.good_number
  668. this.rate_of_concession = warehouseOut.rate_of_concession
  669. this.discount_amount= warehouseOut.discount_amount
  670. this.payment =warehouseOut.payment
  671. this.arrearage =warehouseOut.arrearage
  672. this.supplier_name = warehouseOut.supplier_id
  673. this.return_remake = warehouseOut.return_remake
  674. this.start_time = this.getTimes(warehouseOut.document_date)
  675. for(let i=0;i< orderInfo.length;i++){
  676. orderInfo[i].supply_count = orderInfo[i].count
  677. orderInfo[i].supply_price = orderInfo[i].price
  678. orderInfo[i].supply_remake = orderInfo[i].remark
  679. orderInfo[i].type = orderInfo[i].is_source
  680. orderInfo[i].project_id = orderInfo[i].project_id
  681. orderInfo[i].supply_unit = orderInfo[i].supply_unit
  682. orderInfo[i].order_number = orderInfo[i].order_number
  683. orderInfo[i].supply_total_price = (orderInfo[i].count * orderInfo[i].price).toFixed(2)
  684. orderInfo[i].supply_expiry_date = this.getTimes(orderInfo[i].supply_expiry_date)
  685. orderInfo[i].supply_product_date = this.getTimes(orderInfo[i].supply_product_date)
  686. if(orderInfo[i].is_source == 1){
  687. for(let j=0;j<this.drugList.length;j++){
  688. if( orderInfo[i].project_id == this.drugList[j].id){
  689. if(this.drugList[j].max_unit !=this.drugList[j].min_unit){
  690. orderInfo[i].unitList = [{id:1,name:""},{id:2,name:""}]
  691. orderInfo[i].unitList[0].name = this.drugList[j].max_unit
  692. orderInfo[i].unitList[1].name = this.drugList[j].min_unit
  693. }
  694. if(this.drugList[j].max_unit ==this.drugList[j].min_unit){
  695. orderInfo[i].unitList[0].name = this.drugList[j].max_unit
  696. }
  697. }
  698. }
  699. }
  700. if(orderInfo[i].is_source == 2){
  701. for(let j=0;j<this.goodList.length;j++){
  702. if(orderInfo[i].project_id == this.goodList[j].id){
  703. orderInfo[i].unitList = [{id:1,name:""}]
  704. orderInfo[i].unitList[0].name = this.goodList[j].packing_unit
  705. }
  706. }
  707. }
  708. }
  709. this.recordInfo.tableList= []
  710. this.recordInfo.tableList = orderInfo
  711. }
  712. })
  713. }
  714. })
  715. },
  716. updateGoodOrder(){
  717. if(this.supplier_name == 0 || this.supplier_name == ""){
  718. this.$message.error("供应商不能为空!")
  719. this.loading = false
  720. return false
  721. }
  722. console.log("表哥2323233232",this.recordInfo.tableList)
  723. for(let i=0;i<this.recordInfo.tableList.length;i++){
  724. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count)
  725. this.recordInfo.tableList[i].supply_price = this.recordInfo.tableList[i].supply_price.toString()
  726. this.recordInfo.tableList[i].supply_total_price= this.recordInfo.tableList[i].supply_total_price.toString()
  727. this.recordInfo.tableList[i].supply_total = this.recordInfo.tableList[i].supply_total.toString()
  728. for(let j=0;j<this.manufactuerList.length;j++){
  729. if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name){
  730. this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id
  731. }
  732. if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].id){
  733. this.recordInfo.tableList[i].supply_manufacturer = this.manufactuerList[j].manufacturer_name
  734. }
  735. }
  736. }
  737. var start = this.start_time
  738. this.$refs["tableForm"].validate((valid)=>{
  739. if(valid){
  740. this.loading = true
  741. var warehose_out_id = this.$route.query.id
  742. var params = {
  743. stockIn:this.recordInfo.tableList,
  744. return_remake:this.return_remake,
  745. }
  746. console.log("sotckind23232232323232323232",params)
  747. updateGoodOrder(params,this.supplier_name,start,this.arrearage,this.payment,warehose_out_id,this.number,this.rate_of_concession,this.discount_amount,this.good_number).then(response=>{
  748. if(response.data.state == 1){
  749. this.loading = false
  750. this.$message.success("保存成功!")
  751. }
  752. })
  753. }
  754. })
  755. }
  756. },
  757. created(){
  758. const tempObj = {}
  759. tempObj["id"] = 0
  760. tempObj["name"] = ""
  761. tempObj['supply_name'] = ""
  762. tempObj['supply_type'] = ""
  763. tempObj['supply_specification_name'] = ''
  764. tempObj['supply_total'] = ""
  765. tempObj['supply_count'] = ""
  766. tempObj['supply_price'] = ""
  767. tempObj['supply_total_price'] = ""
  768. tempObj['supply_manufacturer'] = ''
  769. tempObj['supply_license_number'] = ''
  770. tempObj['supply_remake'] = ''
  771. tempObj['type'] = 0
  772. tempObj['is_total'] = 1
  773. tempObj["project_id"] = 0
  774. tempObj["supply_unit"] = ""
  775. tempObj["supply_batch_number"] = ""
  776. tempObj["supply_product_date"] = ""
  777. tempObj["order_number"] = ""
  778. tempObj["supply_expiry_date"] = ""
  779. tempObj["manufacturer_id"] = ""
  780. this.recordInfo.tableList.push(tempObj)
  781. this.getInitOrder()
  782. if(parseInt(this.$route.query.id) > 0){
  783. this.getPurchaseOrderDetail()
  784. }
  785. this.start_time = this.getTimes(new Date())
  786. this.end_time = this.getTimes(new Date())
  787. }
  788. };
  789. </script>
  790. <style rel="stylesheet/css" lang="scss" scoped>
  791. .information {
  792. border: 1px #dcdfe6 solid;
  793. padding: 30px 20px 30px 20px;
  794. .border {
  795. border-bottom: 1px #dcdfe6 solid;
  796. margin: 0px 0 20px 0;
  797. }
  798. }
  799. .title {
  800. background: #409eff;
  801. height: 44px;
  802. line-height: 44px;
  803. padding: 0 0 0 10px;
  804. color: #fff;
  805. margin: 0 0 10px 0;
  806. }
  807. .edit_separater {
  808. border-top: 1px solid rgb(233, 233, 233);
  809. margin-top: 15px;
  810. margin-bottom: 15px;
  811. }
  812. </style>
  813. <style>
  814. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  815. font-size: 12px;
  816. }
  817. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  818. background: #6fb5fa;
  819. }
  820. .count {
  821. color: #bd2c00;
  822. }
  823. .el-table td,
  824. .el-table th.is-leaf,
  825. .el-table--border,
  826. .el-table--group {
  827. border-color: #d0d3da;
  828. }
  829. .el-table--border::after,
  830. .el-table--group::after,
  831. .el-table::before {
  832. background-color: #d0d3da;
  833. }
  834. .el-table__fixed-right{
  835. width:150px;
  836. bottom: 20px;
  837. height: 100%;
  838. }
  839. </style>