addPurchaseOrder.vue 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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 ">
  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. @change="changeTypeName">
  12. <el-option
  13. v-for="item in supplyList"
  14. :key="item.id"
  15. :label="item.supplier_name"
  16. :value="item.id">
  17. </el-option>
  18. </el-select>
  19. <span>单据日期:</span>
  20. <el-date-picker
  21. size="small"
  22. v-model="start_time"
  23. prefix-icon="el-icon-date"
  24. :editable="false"
  25. style="width: 196px;"
  26. type="date"
  27. placeholder="选择日期时间"
  28. align="right"
  29. format="yyyy-MM-dd"
  30. value-format="yyyy-MM-dd"
  31. @change="startTimeChange"
  32. ></el-date-picker>
  33. <span>交货日期:</span>
  34. <el-date-picker
  35. size="small"
  36. v-model="end_time"
  37. prefix-icon="el-icon-date"
  38. :editable="false"
  39. style="width: 196px;"
  40. type="date"
  41. placeholder="选择日期时间"
  42. align="right"
  43. format="yyyy-MM-dd"
  44. value-format="yyyy-MM-dd"
  45. @change="endTimeChange"
  46. ></el-date-picker>
  47. <span>单据编码:</span>
  48. </div>
  49. <div>
  50. <el-button size="small" type="primary" @click="savePurchaseOrder" v-show="showTwo">保存</el-button>
  51. <el-button size="small" type="primary" @click="updatePurchaseOrder" v-show="showOne">修改</el-button>
  52. </div>
  53. </div>
  54. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  55. <el-table
  56. :row-style="{ color: '#303133' }"
  57. :header-cell-style="{
  58. backgroundColor: 'rgb(245, 247, 250)',
  59. color: '#606266'
  60. }"
  61. :data="recordInfo.tableList"
  62. :class="signAndWeighBoxPatients"
  63. border
  64. style="width: 100%"
  65. max-height="450"
  66. >
  67. <el-table-column align="center" width="200px">
  68. <template slot="header" slot-scope="scope">
  69. <span>商品<span style="color: red">*</span></span>
  70. </template>
  71. <template slot-scope="scope">
  72. <el-form-item required prop="name">
  73. <el-select v-model="scope.row.name" style="width:160px;" filterable placeholder="请选择" @change="changeName" @input="changeGoodName(scope.$index)">
  74. <el-option
  75. v-for="(item,index) in tabList"
  76. :key="index"
  77. :label="item.supply_name"
  78. :value="item">
  79. </el-option>
  80. </el-select>
  81. </el-form-item>
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="center" width="150px">
  85. <template slot="header" slot-scope="scope">
  86. <span>商品类别</span>
  87. </template>
  88. <template slot-scope="scope">
  89. <el-input v-model="scope.row.supply_type" style="width:120px" :disabled="true"></el-input>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="规格&单位" align="center" width="200px">
  93. <template slot-scope="scope">
  94. <el-input v-model="scope.row.supply_specification_name" style="width:150px" :disabled="true"></el-input>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="可用库存" align="center" width="130px">
  98. <template slot-scope="scope">
  99. <el-input v-model="scope.row.supply_total" style="width:100px" :disabled="true"></el-input>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="数量" align="center" width="120px">
  103. <template slot="header" slot-scope="scope">
  104. <span>数量<span style="color: red">*</span></span>
  105. </template>
  106. <template slot-scope="scope">
  107. <el-form-item :rules="tableRules.supply_count" required prop="supply_count">
  108. <el-input v-model="scope.row.supply_count" style="width:80px"></el-input>
  109. </el-form-item>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="购货单价" align="center" width="120px">
  113. <template slot-scope="scope">
  114. <el-input v-model="scope.row.supply_price" style="width:80px"></el-input>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="购货金额" align="center" width="120px">
  118. <template slot-scope="scope">
  119. {{calculate(scope.row.supply_count * scope.row.supply_price)}}
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="生产厂商" align="center" width="200px">
  123. <template slot-scope="scope">
  124. <el-input v-model="scope.row.supply_manufacturer" style="width:160px" :disabled="true"></el-input>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="批准文号" align="center" width="200px">
  128. <template slot-scope="scope">
  129. <el-input v-model="scope.row.supply_license_number" style="width:160px"></el-input>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="备注" align="center" width="200px">
  133. <template slot-scope="scope">
  134. <el-input v-model="scope.row.supply_remake" style="width:160px"></el-input>
  135. </template>
  136. </el-table-column>
  137. <el-table-column label="操作" align="center" width="150px" fixed="right" >
  138. <template slot-scope="scope">
  139. <el-tooltip class="item" effect="dark" content="新增" placement="top" >
  140. <el-button
  141. size="mini"
  142. type="primary"
  143. icon="el-icon-circle-plus-outline"
  144. @click="handleEdit(scope.$index, scope.row)">
  145. </el-button>
  146. </el-tooltip>
  147. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  148. <el-button
  149. size="mini"
  150. type="danger"
  151. icon="el-icon-delete"
  152. @click="handleDelete(scope.$index, scope.row)">
  153. </el-button>
  154. </el-tooltip>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. </el-form>
  159. <div style="margin-top:10px">
  160. <span>优惠率:<el-input style="width:100px" v-model="rate_of_concession"></el-input>%</span>
  161. <span>优惠金额:<el-input style="width:100px" v-model="discount_amount"></el-input></span>
  162. </div>
  163. </div>
  164. </div>
  165. </template>
  166. <script>
  167. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  168. import {getInitOrder,savePurchaseOrder} from "@/api/supply"
  169. export default {
  170. name: "addPurchaseOrder",
  171. created() {
  172. this.org_id = this.$store.getters.xt_user.org_id
  173. var start_time = window.sessionStorage.getItem('start_time')
  174. var end_time = window.sessionStorage.getItem('end_time')
  175. if(start_time !=null){
  176. this.start_time = start_time
  177. }
  178. if(end_time!=null){
  179. this.end_time = end_time
  180. }
  181. window.sessionStorage.removeItem('start_time')
  182. window.sessionStorage.removeItem('end_time')
  183. },
  184. components: {
  185. BreadCrumb
  186. },
  187. data() {
  188. return {
  189. crumbs: [
  190. { path: false, name: "购货订单" },
  191. { path: "/spply/query", name: "新增购货订单" }
  192. ],
  193. showTwo:true,
  194. showOne:false,
  195. recordInfo: {
  196. tableList:[],
  197. },
  198. keywords: "",
  199. total: 0,
  200. multipleSelection: [],
  201. signAndWeighBoxPatients: "sign-and-weigh-box-patients",
  202. start_time: "",
  203. end_time: "",
  204. page: 1,
  205. limit: 10,
  206. goodType: [],
  207. goodInfo: [],
  208. org_id:0,
  209. types:[],
  210. tyep_name:"",
  211. form:{
  212. manufacturer_id:"",
  213. },
  214. tabList:[],
  215. manufactuerList:[],
  216. currentIndex: 0,
  217. goodTypeList:[],
  218. drugTypeList:[],
  219. supplier_name:"",
  220. supplyList:[],
  221. rate_of_concession:"",
  222. discount_amount:"",
  223. start_time:new Date(),
  224. end_time:new Date(),
  225. tableRules: {
  226. name: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
  227. supply_count: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
  228. },
  229. };
  230. },
  231. methods:{
  232. getInitOrder(){
  233. getInitOrder().then(response=>{
  234. if(response.data.state == 1){
  235. var drugList = response.data.data.drugList
  236. this.manufactuerList = response.data.data.manufactuerList
  237. this.goodTypeList = response.data.data.goodTypeList
  238. this.drugTypeList = response.data.data.drugTypeList
  239. this.supplyList = response.data.data.supplyList
  240. for(let i=0;i<drugList.length;i++){
  241. for(let z=0;z<drugList[i].drug_warehouse_info.length;z++){
  242. drugList[i].drug_warehouse_info[z].stock_max_number = drugList[i].drug_warehouse_info[z].stock_max_number * drugList[i].min_number
  243. }
  244. for(let j=0;j<this.manufactuerList.length;j++){
  245. if(drugList[i].manufacturer == this.manufactuerList[j].id){
  246. drugList[i].manufacturer = this.manufactuerList[j].manufacturer_name
  247. }
  248. }
  249. for(let y=0;y<this.drugTypeList.length;y++){
  250. if(drugList[i].drug_type == this.drugTypeList[y].value){
  251. drugList[i].drug_type = this.drugTypeList[y].name
  252. }
  253. }
  254. 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
  255. drugList[i].supply_type = drugList[i].drug_type
  256. drugList[i].supply_specification_name = drugList[i].dose +drugList[i].dose_unit+"*"+drugList[i].min_number+ drugList[i].min_unit+"/"+drugList[i].max_unit
  257. drugList[i].supply_total = this.getWarehoseInfo(drugList[i].drug_warehouse_info,drugList[i].max_unit,drugList[i].min_unit,drugList[i].min_number)
  258. drugList[i].supply_count = ""
  259. drugList[i].supply_total_price = ""
  260. drugList[i].supply_manufacturer= drugList[i].manufacturer
  261. drugList[i].supply_license_number= drugList[i].number
  262. drugList[i].supply_remake = ""
  263. drugList[i].type = 1
  264. drugList[i].supply_price = ""
  265. drugList[i].name = drugList[i].drug_name
  266. this.tabList.push(drugList[i])
  267. }
  268. var goodList = response.data.data.goodList
  269. for(let i=0;i<goodList.length;i++){
  270. for(let j=0;j<this.manufactuerList.length;j++){
  271. if(goodList[i].manufacturer == this.manufactuerList[j].id){
  272. goodList[i].manufacturer = this.manufactuerList[j].manufacturer_name
  273. }
  274. }
  275. for(let y=0;y<this.goodTypeList.length;y++){
  276. if(goodList[i].good_type_id == this.goodTypeList[y].id){
  277. goodList[i].good_type_id = this.goodTypeList[y].type_name
  278. }
  279. }
  280. goodList[i].supply_name = goodList[i].good_name + " " + goodList[i].specification_name + " " +goodList[i].manufacturer
  281. goodList[i].supply_type = goodList[i].good_type_id
  282. goodList[i].supply_specification_name =goodList[i].specification_name
  283. goodList[i].supply_price = ""
  284. goodList[i].supply_total = this.getTotalStockCount(goodList[i].good_warehouse_info)
  285. goodList[i].supply_count = ""
  286. goodList[i].supply_total_price = ""
  287. goodList[i].supply_manufacturer = goodList[i].manufacturer
  288. goodList[i].supply_license_number = ""
  289. goodList[i].supply_remake = ""
  290. goodList[i].type = 2
  291. goodList[i].name = goodList[i].good_name
  292. this.tabList.push(goodList[i])
  293. }
  294. }
  295. })
  296. },
  297. changeGoodName(val){
  298. this.currentIndex = val
  299. },
  300. changeName(val){
  301. for(let i=0;i<this.recordInfo.tableList.length;i++){
  302. if(this.currentIndex == i){
  303. this.recordInfo.tableList[i].id = val.id
  304. this.recordInfo.tableList[i].type = val.type
  305. this.recordInfo.tableList[i].name = val.name
  306. this.recordInfo.tableList[i].supply_name = val.supply_name
  307. this.recordInfo.tableList[i].supply_type = val.supply_type
  308. this.recordInfo.tableList[i].supply_specification_name = val.supply_specification_name
  309. this.recordInfo.tableList[i].supply_total = val.supply_total
  310. if(val.supply_count == NaN){
  311. this.recordInfo.tableList[i].supply_count = ""
  312. }else{
  313. this.recordInfo.tableList[i].supply_count = val.supply_count?val.supply_count:""
  314. }
  315. this.recordInfo.tableList[i].supply_price = val.supply_price?val.supply_price:""
  316. this.recordInfo.tableList[i].supply_total_price = val.supply_total_price?val.supply_total_price:""
  317. this.recordInfo.tableList[i].supply_manufacturer = val.supply_manufacturer
  318. this.recordInfo.tableList[i].supply_license_number = val.supply_license_number
  319. this.recordInfo.tableList[i].supply_remake = val.supply_remake
  320. }
  321. }
  322. },
  323. handleEdit(){
  324. const tempObj = {}
  325. tempObj["id"] = ""
  326. tempObj["name"] = ""
  327. tempObj['supply_name'] = ""
  328. tempObj['supply_type'] = ""
  329. tempObj['supply_specification_name'] = ''
  330. tempObj['supply_total'] = ""
  331. tempObj['supply_count'] = ""
  332. tempObj['supply_price'] = ""
  333. tempObj['supply_total_price'] = ""
  334. tempObj['supply_manufacturer'] = ''
  335. tempObj['supply_license_number'] = ''
  336. tempObj['supply_remake'] = ''
  337. tempObj['type'] = 0
  338. this.recordInfo.tableList.push(tempObj)
  339. },
  340. handleDelete: function(index, row) {
  341. if (this.recordInfo.tableList.length <= 1) {
  342. this.$message.error('只有一条记录的时候无法删除')
  343. return
  344. } else {
  345. this.recordInfo.tableList.splice(index, 1)
  346. }
  347. },
  348. savePurchaseOrder(){
  349. // console.log("tablelsit323232",this.recordInfo.tableList)
  350. console.log("hhh232323",this.$refs)
  351. this.$refs["tableForm"].validate((valid)=>{
  352. if(valid){
  353. var params = {
  354. supplier_name:this.supplier_name,
  355. start_time:this.start_time,
  356. end_time:this.end_time,
  357. rate_of_concession:this.rate_of_concession,
  358. discount_amount:this.discount_amount,
  359. }
  360. console.log("partam2332232332",params)
  361. console.log("tablelsit323232",this.recordInfo.tableList)
  362. for(let i=0;i<this.recordInfo.tableList.length;i++){
  363. this.recordInfo.tableList[i].supply_count = parseInt(this.recordInfo.tableList[i].supply_count)
  364. for(let j=0;j<this.manufactuerList.length;j++){
  365. if(this.recordInfo.tableList[i].supply_manufacturer == this.manufactuerList[j].manufacturer_name){
  366. this.recordInfo.tableList[i].manufacturer_id = this.manufactuerList[j].id
  367. }
  368. }
  369. }
  370. return
  371. savePurchaseOrder(this.recordInfo.tableList,this.supplier_name,this.start_time,this.end_time,this.rate_of_concession,this.discount_amount).then(response=>{
  372. if(response.data.state == 1){
  373. var order = response.data.data.order
  374. this.$message.success("保存成功!")
  375. this.showTwo = false
  376. this.showOne = true
  377. }
  378. })
  379. }
  380. })
  381. },
  382. changeTypeName(){
  383. },
  384. startTimeChange(){
  385. },
  386. endTimeChange(){
  387. },
  388. search(){
  389. },
  390. getWarehoseInfo(arr,max_unit,min_unit,min_number){
  391. var total = 0
  392. var max_str= ""
  393. var min_str = ""
  394. if (arr.length > 0) {
  395. for(let i=0;i<arr.length;i++){
  396. total += parseInt(arr[i].stock_max_number)
  397. }
  398. }
  399. if (total < min_number){
  400. min_str = total + min_unit
  401. }
  402. if (total == 0) {
  403. min_str = ""
  404. max_str = ""
  405. }
  406. if (total >=min_number) {
  407. if(parseInt(total/min_number)!=0){
  408. max_str = parseInt(total/min_number) + max_unit
  409. }
  410. if(total%min_number!=0){
  411. min_str = total%min_number + min_unit
  412. }
  413. }
  414. return max_str + min_str
  415. },
  416. getTotalStockCount(arr){
  417. var total_count = 0
  418. for(let i=0;i<arr.length;i++){
  419. total_count += arr[i].stock_count
  420. }
  421. return total_count
  422. },
  423. calculate: function(val) {
  424. if (isNaN(val)) {
  425. return "";
  426. }
  427. if (val == 0) {
  428. return "";
  429. }
  430. return Math.round(parseFloat(val) * 100) / 100;
  431. },
  432. updatePurchaseOrder(){
  433. }
  434. },
  435. created(){
  436. const tempObj = {}
  437. tempObj["id"] = ""
  438. tempObj["name"] = ""
  439. tempObj['supply_name'] = ""
  440. tempObj['supply_type'] = ""
  441. tempObj['supply_specification_name'] = ''
  442. tempObj['supply_total'] = ""
  443. tempObj['supply_count'] = ""
  444. tempObj['supply_price'] = ""
  445. tempObj['supply_total_price'] = ""
  446. tempObj['supply_manufacturer'] = ''
  447. tempObj['supply_license_number'] = ''
  448. tempObj['supply_remake'] = ''
  449. tempObj['type'] = 0
  450. this.recordInfo.tableList.push(tempObj)
  451. this.getInitOrder()
  452. }
  453. };
  454. </script>
  455. <style rel="stylesheet/css" lang="scss" scoped>
  456. .information {
  457. border: 1px #dcdfe6 solid;
  458. padding: 30px 20px 30px 20px;
  459. .border {
  460. border-bottom: 1px #dcdfe6 solid;
  461. margin: 0px 0 20px 0;
  462. }
  463. }
  464. .title {
  465. background: #409eff;
  466. height: 44px;
  467. line-height: 44px;
  468. padding: 0 0 0 10px;
  469. color: #fff;
  470. margin: 0 0 10px 0;
  471. }
  472. .edit_separater {
  473. border-top: 1px solid rgb(233, 233, 233);
  474. margin-top: 15px;
  475. margin-bottom: 15px;
  476. }
  477. </style>
  478. <style>
  479. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  480. font-size: 12px;
  481. }
  482. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  483. background: #6fb5fa;
  484. }
  485. .count {
  486. color: #bd2c00;
  487. }
  488. .el-table td,
  489. .el-table th.is-leaf,
  490. .el-table--border,
  491. .el-table--group {
  492. border-color: #d0d3da;
  493. }
  494. .el-table--border::after,
  495. .el-table--group::after,
  496. .el-table::before {
  497. background-color: #d0d3da;
  498. }
  499. .el-table__fixed-right{
  500. width:150px;
  501. bottom: 20px;
  502. height: 200px;
  503. }
  504. </style>