drugStockInOrderAdd.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb v-if="type == 1" :crumbs='crumbs'></bread-crumb>
  5. <bread-crumb v-if="type == 2" :crumbs='crumbs2'></bread-crumb>
  6. <div style="float:right;">
  7. <el-button size="small" @click="back()" class="filter-item">取 消</el-button>
  8. <el-button size="small" type="primary" @click="submit()" class="filter-item">保 存</el-button>
  9. </div>
  10. </div>
  11. <div class="app-container" v-loading="loading">
  12. <drugs-stock-dialog
  13. ref="dialog"
  14. :propForm="propForm"
  15. :visibility="isVisibility"
  16. v-on:dialog-comfirm="comfirm"
  17. v-on:dialog-cancle="cancle"
  18. ></drugs-stock-dialog>
  19. <div class="cell clearfix">
  20. <label class="title"><span class="name"><span style="color:red">*</span>仓库</span> :</label>
  21. <el-select size="small" v-model="storehouse_id" filterable placeholder="请选择仓库" style="width:200px">
  22. <el-option
  23. v-for="(option, index) in list"
  24. :key="index"
  25. :label="option.storehouse_name"
  26. :value="option.id">
  27. </el-option>
  28. </el-select>
  29. <label class="title"><span class="name">入库时间</span> : </label>
  30. <el-date-picker size="small" v-model="warehousing_time" prefix-icon="el-icon-date" :editable="false"
  31. style="width: 196px;" type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  32. value-format="yyyy-MM-dd"></el-date-picker>
  33. <div class="titleOne">制单人:{{this.$store.getters.xt_user.user.user_name}}</div>
  34. </div>
  35. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  36. <el-table
  37. id="oictable"
  38. :data="recordInfo.recordData"
  39. :class="signAndWeighBoxPatients"
  40. style="width: 100%"
  41. border
  42. max-height="450"
  43. v-loading="listLoading"
  44. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  45. >
  46. <el-table-column align="center" width="200" fixed="left">
  47. <template slot="header" slot-scope="scope">
  48. <span>药品名称<span style="color: red">*</span></span>
  49. </template>
  50. <template slot-scope="scope">
  51. <el-form-item style="padding-top: 20px">
  52. <el-autocomplete
  53. class="checkSearch"
  54. popper-class="my-autocomplete"
  55. v-model="scope.row.drug_name"
  56. :fetch-suggestions="querySearchAsync"
  57. :trigger-on-focus="true"
  58. placeholder="请输入药品名称"
  59. @select="handleSelect"
  60. @input="changeDrugName(scope.$index)"
  61. style="width:160px;"
  62. >
  63. <i class="el-icon-search el-input__icon" slot="suffix"></i>
  64. <template slot-scope="{ item }">
  65. <div class="name">{{ item.drug_name + item.dose + item.dose_unit + "*" +item.min_number + item.min_unit +"/" + item.max_unit + " "+item.manufacturer}}</div>
  66. </template>
  67. </el-autocomplete>
  68. </el-form-item>
  69. </template>
  70. </el-table-column>
  71. <el-table-column align="center" width="140">
  72. <template slot="header" slot-scope="scope">
  73. <span>药品类型</span>
  74. </template>
  75. <template slot-scope="scope">
  76. <el-select v-model="scope.row.drug_type" filterable placeholder="请选择药品类型">
  77. <el-option
  78. v-for="(option, index) in drugTypeList"
  79. :key="index"
  80. :label="option.name"
  81. :value="option.id">
  82. </el-option>
  83. </el-select>
  84. </template>
  85. </el-table-column>
  86. <el-table-column align="center" width="140">
  87. <template slot="header" slot-scope="scope">
  88. <span>规格&单位</span>
  89. </template>
  90. <template slot-scope="scope">
  91. <el-form-item style="padding-top: 20px">
  92. <el-input
  93. :disabled="true"
  94. placeholder="请输入规格&单位"
  95. v-model="scope.row.name"
  96. ></el-input>
  97. </el-form-item>
  98. </template>
  99. </el-table-column>
  100. <el-table-column align="center" width="150">
  101. <template slot="header" slot-scope="scope" >
  102. <span >批号<span style="color: red">*</span></span>
  103. </template>
  104. <template slot-scope="scope">
  105. <el-form-item style="padding-top: 20px" :rules="tableRules.batch_number" :prop="'recordData.' + scope.$index + '.batch_number'">
  106. <el-input
  107. placeholder="请输入批号"
  108. v-model="scope.row.batch_number"
  109. ></el-input>
  110. </el-form-item>
  111. </template>
  112. </el-table-column>
  113. <el-table-column align="center" width="200">
  114. <template slot="header" slot-scope="scope">
  115. <span>入库数量<span style="color: red">*</span></span>
  116. </template>
  117. <template slot-scope="scope">
  118. <el-form-item
  119. :prop="'recordData.' + scope.$index + '.warehousing_count'"
  120. :rules="tableRules.warehousing_count"
  121. style="padding-top: 10px"
  122. >
  123. <div style="display:flex;">
  124. <!-- <el-input
  125. oninput="value=value.replace(/\D|^0/g,'')"
  126. placeholder="请输入入库数量"
  127. type="number"
  128. v-model="scope.row.warehousing_count"
  129. style="width:120px"
  130. ></el-input> -->
  131. <el-input
  132. placeholder="请输入入库数量"
  133. v-model="scope.row.warehousing_count"
  134. style="width:120px"
  135. ></el-input>
  136. <!-- {{scope.row.max_unit}} -->
  137. <el-select v-model="scope.row.max_unit" filterable placeholder="请选择单位" style="width:80px">
  138. <el-option
  139. v-for="(option, index) in unitList"
  140. :key="index"
  141. :label="option.name"
  142. :value="option.name">
  143. </el-option>
  144. </el-select>
  145. </div>
  146. </el-form-item>
  147. </template>
  148. </el-table-column>
  149. <el-table-column align="center" width="140">
  150. <template slot="header" slot-scope="scope">
  151. <span>拆零零售价(元)<span style="color: red">*</span></span>
  152. </template>
  153. <template slot-scope="scope">
  154. <el-form-item
  155. :prop="'recordData.' + scope.$index + '.retail_price'"
  156. :rules="tableRules.retail_price"
  157. style="padding-top: 20px"
  158. >
  159. <el-input
  160. style="width:100px"
  161. placeholder="请输入拆零零售价"
  162. type="number"
  163. v-model="scope.row.retail_price"
  164. ></el-input>
  165. </el-form-item>
  166. </template>
  167. </el-table-column>
  168. <el-table-column align="center" width="120">
  169. <template slot="header" slot-scope="scope">
  170. <span>进货单价(元)<span style="color: red">*</span></span>
  171. </template>
  172. <template slot-scope="scope">
  173. <el-form-item
  174. :prop="'recordData.' + scope.$index + '.price'"
  175. :rules="tableRules.last_price"
  176. style="padding-top: 20px"
  177. >
  178. <el-input
  179. style="width:100px"
  180. placeholder="请输入单价"
  181. type="number"
  182. v-model="scope.row.last_price"
  183. ></el-input>
  184. </el-form-item>
  185. </template>
  186. </el-table-column>
  187. <el-table-column label="总价(元)" align="center" width="80">
  188. <template slot-scope="scope">
  189. {{ calculate(scope.row.last_price * scope.row.warehousing_count) }}
  190. </template>
  191. </el-table-column>
  192. <el-table-column width="180" align="center">
  193. <template slot="header" slot-scope="scope">
  194. <span>有效日期<span style="color: red">*</span></span>
  195. </template>
  196. <template slot-scope="scope">
  197. <el-form-item :prop="'recordData.' + scope.$index + '.expiry_date'"
  198. :rules="tableRules.expiry_date"
  199. style="padding-top: 20px">
  200. <el-date-picker
  201. prefix-icon="el-icon-date"
  202. style="width: 145px"
  203. v-model="scope.row.expiry_date"
  204. type="date"
  205. placeholder="选择日期时间"
  206. format="yyyy-MM-dd"
  207. value-format="yyyy-MM-dd"
  208. ></el-date-picker>
  209. </el-form-item>
  210. </template>
  211. </el-table-column>
  212. <el-table-column label="生产日期" width="180" align="center">
  213. <template slot-scope="scope">
  214. <el-date-picker
  215. prefix-icon="el-icon-date"
  216. style="width: 145px"
  217. v-model="scope.row.product_date"
  218. type="date"
  219. placeholder="选择日期时间"
  220. format="yyyy-MM-dd"
  221. value-format="yyyy-MM-dd"
  222. ></el-date-picker>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="生产厂家" width="140" align="center">
  226. <template slot-scope="scope">
  227. <el-select v-model="scope.row.manufacturer" filterable placeholder="请选择厂商">
  228. <el-option
  229. v-for="(option, index) in manufacturerList"
  230. :key="index"
  231. :label="option.manufacturer_name"
  232. :value="option.id">
  233. </el-option>
  234. </el-select>
  235. </template>
  236. </el-table-column>
  237. <el-table-column label="经销商" width="140" align="center">
  238. <template slot-scope="scope">
  239. <el-select v-model="scope.row.dealer" filterable placeholder="请选择厂商">
  240. <el-option
  241. v-for="(option, index) in dealerList"
  242. :key="index"
  243. :label="option.dealer_name"
  244. :value="option.id">
  245. </el-option>
  246. </el-select>
  247. </template>
  248. </el-table-column>
  249. <el-table-column align="center" width="150" label="批准文号">
  250. <template slot-scope="scope">
  251. <el-form-item style="padding-top: 20px">
  252. <el-input
  253. placeholder="请输入批准文号"
  254. v-model="scope.row.number"
  255. ></el-input>
  256. </el-form-item>
  257. </template>
  258. </el-table-column>
  259. <el-table-column label="备注" width="150" align="center">
  260. <template slot-scope="scope">
  261. <el-input v-model="scope.row.remark"></el-input>
  262. </template>
  263. </el-table-column>
  264. <el-table-column
  265. label="操作"
  266. fixed="right"
  267. align="center"
  268. width="150"
  269. >
  270. <template slot-scope="scope">
  271. <el-tooltip
  272. class="item"
  273. effect="dark"
  274. content="新增"
  275. placement="top"
  276. >
  277. <el-button
  278. size="mini"
  279. type="primary"
  280. icon="el-icon-circle-plus-outline"
  281. @click="handleEdit(scope.$index, scope.row)"
  282. >
  283. </el-button>
  284. </el-tooltip>
  285. <el-tooltip
  286. class="item"
  287. effect="dark"
  288. content="删除"
  289. placement="top"
  290. >
  291. <el-button
  292. size="mini"
  293. type="danger"
  294. icon="el-icon-delete"
  295. @click="handleDelete(scope.$index, scope.row)"
  296. >
  297. </el-button>
  298. </el-tooltip>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. </el-form>
  303. </div>
  304. </div>
  305. </template>
  306. <script>
  307. import { uParseTime } from '@/utils/tools'
  308. import {
  309. GetAllConfig,
  310. GetAllDrugInfoByID,
  311. postDrugWarehouse
  312. } from "@/api/drug/drug_stock";
  313. import BreadCrumb from '../../components/bread-crumb'
  314. import DrugsStockDialog from './drugsStockDialog/index'
  315. import {getDataConfig, getDictionaryDataConfig } from "@/utils/data";
  316. import {getAllDrugList,postSearchDrugList } from "@/api/data"
  317. export default {
  318. components: { DrugsStockDialog, BreadCrumb },
  319. name: 'stockIn',
  320. data() {
  321. var checkGoodId = (rule, value, callback) => {
  322. setTimeout(() => {
  323. if (value == '' || value == 0) {
  324. return callback(new Error('规格名称不能为空'))
  325. }
  326. }, 2000)
  327. }
  328. return {
  329. crumbs: [
  330. { path: false, name: '库存管理' },
  331. { path: false, name: "药品入库单" },
  332. { path: false, name: "新增入库单" }
  333. ],
  334. crumbs2: [
  335. { path: false, name: '库存管理' },
  336. { path: false, name: '其他入库单' },
  337. { path: false, name: '新增入库单' }
  338. ],
  339. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  340. warehousing_time: '',
  341. adminUserOptions: null,
  342. currentIndex: 0,
  343. listLoading: false,
  344. recordInfo: {
  345. recordData: [],
  346. stock_in_code: '',
  347. current_index: ''
  348. },
  349. tableRules: {
  350. price: [
  351. { required: true, message: '单价不能为空', trigger: 'blur' }
  352. ],
  353. warehousing_count: [
  354. { required: true, message: '数量不能为空', trigge: 'blur' }
  355. ],
  356. good_id: [
  357. { validator: checkGoodId, trigger: 'blur' }
  358. ],
  359. min_unit:[
  360. {required:true,message:'单位不能为空',trigger:'blur'}
  361. ],
  362. batch_number:[
  363. {required:true,message:'批号不能为空',trigger:'blur'}
  364. ],
  365. expiry_date:[
  366. {required:true,message:'有效日期不能为空',trigger:'blur'}
  367. ],
  368. retail_price:[
  369. {required:true,message:'请输入包装零售价',trigger:'blur'}
  370. ]
  371. },
  372. type: this.$route.query.type,
  373. total: '',
  374. product_date: '',
  375. expiry_date: '',
  376. numbers: '',
  377. // prop
  378. isVisibility: false,
  379. propForm: {
  380. goods: [],
  381. goodType: [],
  382. goodInfo: [],
  383. goodUnit: [],
  384. title: '入库',
  385. formValue: {
  386. good_type_id: '',
  387. good_id: '',
  388. number: '',
  389. product_date: '',
  390. expiry_date: '',
  391. warehousing_count: '',
  392. price: '',
  393. remark: '',
  394. dealer: '',
  395. manufacturer: ''
  396. },
  397. isCreated: 1
  398. },
  399. form: {
  400. manufacturer: '',
  401. dealer: ''
  402. },
  403. formValue: {
  404. good_type_id: '',
  405. good_id: '',
  406. number: '',
  407. product_date: '',
  408. expiry_date: '',
  409. warehousing_count: '',
  410. price: '',
  411. remark: '',
  412. dealer: '',
  413. manufacturer: ''
  414. },
  415. manufacturer: [],
  416. dealer: [],
  417. goodType: [],
  418. goodInfo:[],
  419. drugList:[],
  420. manufacturerList:[],
  421. dealerList:[],
  422. showOne:true,
  423. showTwo:false,
  424. drugTypeList:[],
  425. totalPrice:0,
  426. unitList:[],
  427. loading:false,
  428. list:[],
  429. storehouse_id:"",
  430. }
  431. },
  432. methods: {
  433. handleSave: function() {
  434. if (this.recordInfo.recordData.length <= 0) {
  435. this.$message.error('请添加入库信息')
  436. return
  437. }
  438. sessionStorage.removeItem('warehousing_orders')
  439. this.$router.back(-1)
  440. }, handleCancle: function() {
  441. this.$confirm('是否放弃编辑返回上一页?', '放弃编辑', {
  442. confirmButtonText: '确定',
  443. cancelButtonText: '取消',
  444. type: 'warning'
  445. }).then(() => {
  446. sessionStorage.removeItem('warehousing_orders')
  447. this.$router.back(-1)
  448. }).catch(() => {
  449. })
  450. }, handleCreate: function() {
  451. this.propForm.formValue = {}
  452. this.propForm.isCreated = 1
  453. this.isVisibility = true
  454. },
  455. comfirm: function(val) {
  456. this.$refs.dialog.hide()
  457. if (val.selectedGoodInfo.length > 0) {
  458. for (let i = val.selectedGoodInfo.length - 1; i >= 0; i--) {
  459. if (i == 0) {
  460. this.recordInfo.recordData[this.currentIndex].drug_id = val.selectedGoodInfo[i].id
  461. this.recordInfo.recordData[this.currentIndex].price = val.selectedGoodInfo[i].last_price.toString()
  462. this.recordInfo.recordData[this.currentIndex].retail_price = val.selectedGoodInfo[i].retail_price.toString()
  463. this.recordInfo.recordData[this.currentIndex].min_unit = val.selectedGoodInfo[i].min_unit
  464. } else {
  465. const tempForm = {}
  466. tempForm["id"] = 0;
  467. tempForm['drug_id'] = val.selectedGoodInfo[i].id
  468. tempForm['number'] = ''
  469. tempForm['product_date'] = ''
  470. tempForm['expiry_date'] = ''
  471. tempForm['warehousing_count'] = ''
  472. tempForm['retail_price'] = val.selectedGoodInfo[i].retail_price.toString()
  473. tempForm['price'] = val.selectedGoodInfo[i].last_price.toString()
  474. tempForm['remark'] = ''
  475. tempForm['dealer'] = ''
  476. tempForm['manufacturer'] = ''
  477. tempForm['min_unit']= val.selectedGoodInfo[i].min_unit
  478. this.recordInfo.recordData.splice(this.currentIndex + 1, 0, tempForm)
  479. }
  480. }
  481. }
  482. this.currentIndex = -1
  483. },
  484. cancle: function() {
  485. this.$refs.dialog.hide()
  486. },
  487. GetConfigInfo: function() {
  488. const loading = this.$loading({
  489. lock: true,
  490. text: 'Loading',
  491. spinner: 'el-icon-loading',
  492. background: 'rgba(0, 0, 0, 0.7)'
  493. })
  494. GetAllConfig().then(response => {
  495. if (response.data.state == 0) {
  496. this.$message.error(response.data.msg)
  497. return false
  498. } else {
  499. this.manufacturer = response.data.data.manufacturer;
  500. this.dealer = response.data.data.dealer;
  501. for(let i = 0; i< response.data.data.drugs.length;i++){
  502. this.goodType.push(response.data.data.drugs[i])
  503. if(response.data.data.drugs[i].drug_specs != null) {
  504. for (let b = 0; b < response.data.data.drugs[i].drug_specs.length; b++) {
  505. this.goodInfo.push(response.data.data.drugs[i].drug_specs[b])
  506. }
  507. }
  508. }
  509. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: "全部" });
  510. this.dealer.splice(0, 0, { id: 0, dealer_name: "全部" });
  511. this.form.manufacturer = 0
  512. this.form.dealer = 0
  513. this.list = response.data.data.list
  514. this.storehouse_id = response.data.data.configlist.drug_storehouse_info
  515. }
  516. loading.close()
  517. })
  518. },
  519. typeName: function(drug_id) {
  520. let name = "";
  521. for (let i = 0; i < this.goodInfo.length; i++) {
  522. if (this.goodInfo[i].id == drug_id) {
  523. name = this.goodInfo[i].drug_name;
  524. }
  525. }
  526. return name;
  527. },
  528. specificationName: function(drug_id) {
  529. let name = "";
  530. for (let i = 0; i < this.goodInfo.length; i++) {
  531. if (this.goodInfo[i].id == drug_id) {
  532. name = this.goodInfo[i].drug_spec;
  533. }
  534. }
  535. return name;
  536. },
  537. getDrugName:function(drug_id){
  538. let name = ""
  539. for(let i=0;i<this.recordInfo.recordData.length;i++){
  540. if(drug_id == this.recordInfo.recordData[i].id){
  541. name = this.recordInfo.recordData[i].dose + this.recordInfo.recordData[i].dose_unit + "*" + this.recordInfo.recordData[i].min_number + this.recordInfo.recordData[i].min_unit + "/"+this.recordInfo.recordData[i].max_unit
  542. }
  543. }
  544. return name
  545. },
  546. handleEdit: function(index, row) {
  547. const tempObj = {}
  548. tempObj['drug_name'] = ''
  549. tempObj['drug_id'] = 0
  550. tempObj['number'] = ''
  551. tempObj['product_date'] = ''
  552. tempObj['expiry_date'] = ''
  553. tempObj['warehousing_count'] = ''
  554. tempObj['retail_price'] = ''
  555. tempObj['price'] = ''
  556. tempObj['remark'] = ''
  557. tempObj['dealer'] = ''
  558. tempObj['manufacturer'] = ''
  559. tempObj['min_unit'] = ''
  560. tempObj['max_unit'] = ''
  561. tempObj["drug_type"] = ''
  562. tempObj['batch_number'] = ''
  563. tempObj['dose']= ''
  564. tempObj['dose_unit']=''
  565. tempObj['dealer'] = ''
  566. tempObj['last_price'] = ''
  567. this.recordInfo.recordData.push(tempObj)
  568. }, handleDelete: function(index, row) {
  569. if (this.recordInfo.recordData.length <= 1) {
  570. this.$message.error('只有一条记录的时候无法删除')
  571. return
  572. } else {
  573. this.recordInfo.recordData.splice(index, 1)
  574. }
  575. }, calculate: function(val) {
  576. if (val == 0) {
  577. return ''
  578. }
  579. return Math.round(parseFloat(val) * 100) / 100
  580. },
  581. getTime(val, temp) {
  582. if (val != 0) {
  583. return uParseTime(val, temp)
  584. } else {
  585. return ''
  586. }
  587. },
  588. showDialog(index, row) {
  589. const loading = this.$loading({
  590. lock: true,
  591. text: 'Loading',
  592. spinner: 'el-icon-loading',
  593. background: 'rgba(0, 0, 0, 0.7)'
  594. })
  595. this.currentIndex = index
  596. this.isVisibility = true
  597. const params = {
  598. manufacturer_id: this.form.manufacturer,
  599. dealer_id: this.form.dealer
  600. }
  601. GetAllDrugInfoByID(params).then(response => {
  602. if (response.data.state == 0) {
  603. this.$message.error(response.data.msg)
  604. return false
  605. loading.close()
  606. } else {
  607. loading.close()
  608. if (response.data.data.drugs.length <= 0) {
  609. this.$message.error('该厂商或经销商没有药品信息')
  610. return
  611. }
  612. for (let i = 0; i < response.data.data.drugs.length; i++) {
  613. this.propForm.goods.push(
  614. response.data.data.drugs[i]
  615. );
  616. }
  617. this.$refs.dialog.show()
  618. const obj = {};
  619. this.propForm.goods = this.propForm.goods.reduce(
  620. (cur, next) => {
  621. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  622. return cur;
  623. },
  624. []
  625. ); // 设置cur默认类型为数组,并且初始值为空的数组
  626. }
  627. for (let i = 0; i < this.propForm.goods.length; i++) {
  628. for (let a = 0; a < this.propForm.goods[i].drug_specs.length; a++) {
  629. var respObj = this.propForm.goods[i].drug_specs[a];
  630. respObj["isSelected"] = false;
  631. }
  632. }
  633. }
  634. )
  635. },
  636. getSummaries(param) {
  637. const { columns, data } = param
  638. const sums = []
  639. columns.forEach((column, index) => {
  640. if (index === 0) {
  641. sums[index] = '总价'
  642. return
  643. }
  644. const values = data.map(item => Number(item[column.property]))
  645. if (!values.every(value => isNaN(value))) {
  646. sums[index] = values.reduce((prev, curr) => {
  647. const value = Number(curr)
  648. if (!isNaN(value)) {
  649. return prev + curr
  650. } else {
  651. return prev
  652. }
  653. }, 0)
  654. sums[index] += ' 元'
  655. } else {
  656. sums[index] = 'N/A'
  657. }
  658. })
  659. return sums
  660. }
  661. ,
  662. back() {
  663. this.$router.go(-1)
  664. }
  665. ,
  666. submit() {
  667. this.$refs['tableForm'].validate((valid) => {
  668. if (valid) {
  669. this.loading = true
  670. const array = this.recordInfo.recordData
  671. if(this.storehouse_id == 0){
  672. this.$message.error("仓库不能为空!")
  673. return false
  674. }
  675. for (let i = 0; i < array.length; i++) {
  676. if (array[i].drug_id == 0) {
  677. this.$message.error('药品名称或者药品规格名称不能为空')
  678. return
  679. }
  680. }
  681. if(this.recordInfo.recordData.length <= 0){
  682. this.$message.success('请添加入库商品')
  683. return
  684. }
  685. for(let i=0;i<this.recordInfo.recordData.length;i++){
  686. if(this.recordInfo.recordData[i].dealer == ""){
  687. this.recordInfo.recordData[i].dealer = 0
  688. }
  689. this.recordInfo.recordData[i].last_price = this.recordInfo.recordData[i].last_price.toString()
  690. this.recordInfo.recordData[i].retail_price = this.recordInfo.recordData[i].retail_price.toString()
  691. if(this.recordInfo.recordData[i].dealer == ""){
  692. this.recordInfo.recordData[i].dealer = 0
  693. }
  694. for(let j=0;j<this.manufacturerList.length;j++){
  695. if(this.recordInfo.recordData[i].manufacturer == this.manufacturerList[j].manufacturer_name){
  696. this.recordInfo.recordData[i].manufacturer = this.manufacturerList[j].id
  697. }
  698. }
  699. for(let z=0;z<this.dealerList.length;z++){
  700. if(this.recordInfo.recordData[i].dealer == this.dealerList[z].dealer_name){
  701. this.recordInfo.recordData[i].dealer = this.dealerList[z].id
  702. }
  703. }
  704. }
  705. const params = {
  706. 'stockIn': this.recordInfo.recordData
  707. }
  708. postDrugWarehouse(params, this.warehousing_time, this.form.manufacturer, this.form.dealer, this.type,this.storehouse_id).then(response => {
  709. if (response.data.state == 0) {
  710. this.loading = false
  711. this.$message.error(response.data.msg)
  712. return false
  713. } else {
  714. this.loading = false
  715. this.$message.success('入库成功')
  716. this.listLoading = false
  717. this.$router.back(-1)
  718. }
  719. })
  720. } else {
  721. return false
  722. }
  723. })
  724. }
  725. ,
  726. changeManufacturer(val) {
  727. },
  728. changeDealer(val) {
  729. this.form.dealer = val;
  730. this.propForm.goods= []
  731. },
  732. getDataConfig(module, filed_name){
  733. return getDataConfig(module, filed_name)
  734. },
  735. getDictionaryDataConfig(module, filed_name) {
  736. return getDictionaryDataConfig(module, filed_name)
  737. },
  738. // 改版后的JS
  739. getlist(){
  740. getAllDrugList().then(response=>{
  741. if(response.data.state == 1){
  742. var list = response.data.data.list
  743. this.drugList = list
  744. var manufacturerList = response.data.data.manufacturerList
  745. this.manufacturerList = manufacturerList
  746. for(let i=0;i<this.drugList.length;i++){
  747. for(let j=0;j<this.manufacturerList.length;j++){
  748. if(this.drugList[i].manufacturer == this.manufacturerList[j].id){
  749. this.drugList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  750. }
  751. }
  752. }
  753. }
  754. })
  755. },
  756. changeDrugName(val){
  757. this.showOne = false
  758. this.showTwo = true
  759. },
  760. querySearchAsync(keyword, cb) {
  761. let key = '';
  762. if (keyword != undefined) {
  763. key = keyword
  764. }
  765. let searchArray = [];
  766. postSearchDrugList(key,this.storehouse_id).then(response => {
  767. if (response.data.state == 1) {
  768. searchArray = response.data.data.list;
  769. var list = response.data.data.list
  770. this.drugList = list
  771. var manufacturerList = response.data.data.manufacturerList
  772. this.manufacturerList = manufacturerList
  773. var dealerList = response.data.data.dealerList
  774. this.dealerList = dealerList
  775. for(let i=0;i<this.drugList.length;i++){
  776. for(let j=0;j<this.manufacturerList.length;j++){
  777. if(this.drugList[i].manufacturer == this.manufacturerList[j].id){
  778. this.drugList[i].manufacturer = this.manufacturerList[j].manufacturer_name
  779. }
  780. }
  781. for(let z=0;z<dealerList.length;z++){
  782. if(this.drugList[i].dealer == this.dealerList[z].id){
  783. this.drugList[i].dealer = this.dealerList[z].dealer_name
  784. }
  785. }
  786. }
  787. cb(this.drugList)
  788. } else {
  789. cb([])
  790. }
  791. })
  792. },
  793. changeDrugName(val){
  794. this.currentIndex = val
  795. },
  796. handleSelect(val){
  797. for(let i=0;i<this.recordInfo.recordData.length;i++){
  798. if(i == this.currentIndex){
  799. this.recordInfo.recordData[i].drug_id = val.id
  800. this.recordInfo.recordData[i].drug_name = val.drug_name
  801. this.recordInfo.recordData[i].drug_type = val.drug_type
  802. this.recordInfo.recordData[i].name = val.dose +val.dose_unit+"*"+val.min_number+ val.min_unit+"/"+val.max_unit
  803. this.recordInfo.recordData[i].last_price = val.last_price
  804. this.recordInfo.recordData[i].retail_price = val.min_price
  805. this.recordInfo.recordData[i].manufacturer = val.manufacturer
  806. this.recordInfo.recordData[i].number = val.number
  807. this.recordInfo.recordData[i].max_unit = val.max_unit
  808. this.recordInfo.recordData[i].min_unit = val.min_unit
  809. if(val.dealer == 0){
  810. this.recordInfo.recordData[i].dealer = ""
  811. }else{
  812. this.recordInfo.recordData[i].dealer = val.dealer
  813. }
  814. }
  815. }
  816. }
  817. }
  818. ,
  819. created() {
  820. this.drugTypeList = getDictionaryDataConfig('system','drug_type')
  821. var nowDate = new Date()
  822. var nowYear = nowDate.getFullYear()
  823. var nowMonth = nowDate.getMonth() + 1
  824. var nowDay = nowDate.getDate()
  825. this.warehousing_time =
  826. nowYear +
  827. '-' +
  828. (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
  829. '-' +
  830. (nowDay < 10 ? '0' + nowDay : nowDay)
  831. const tempObj = {}
  832. tempObj['drug_id'] = 0
  833. tempObj['drug_name'] = ''
  834. tempObj['dosage'] = ''
  835. tempObj['max_unit'] = ''
  836. tempObj['min_unit'] = '',
  837. tempObj['lot_number'] = ''
  838. tempObj['product_date'] = ''
  839. tempObj['expiry_date'] = ''
  840. tempObj['warehousing_count'] = ''
  841. tempObj['retail_price'] = ''
  842. tempObj['last_price'] = ''
  843. tempObj['remark'] = ''
  844. tempObj['dealer'] = ''
  845. tempObj['manufacturer'] = ''
  846. tempObj['batch_number'] = ''
  847. tempObj['drug_type'] = ''
  848. tempObj['dealer'] = ''
  849. tempObj["number"] = ''
  850. this.recordInfo.recordData.push(tempObj)
  851. this.GetConfigInfo()
  852. this.propForm.goodUnit = this.$store.getters.good_unit
  853. this.unitList = getDataConfig('hemodialysis','units')
  854. }
  855. }
  856. </script>
  857. <style>
  858. #oictable ::-webkit-scrollbar {
  859. height: 15px;
  860. }
  861. </style>
  862. <style rel="stylesheet/css" lang="scss" scoped>
  863. .information {
  864. border: 1px #dcdfe6 solid;
  865. padding: 30px 20px 30px 20px;
  866. .border {
  867. border-bottom: 1px #dcdfe6 solid;
  868. margin: 0px 0 20px 0;
  869. }
  870. }
  871. .edit_separater {
  872. border-top: 1px solid rgb(233, 233, 233);
  873. margin-top: 15px;
  874. margin-bottom: 15px;
  875. }
  876. .titleOne {
  877. width: 120px;
  878. display: inline-block;
  879. font-weight: normal;
  880. color: #909399;
  881. padding: 6px 0;
  882. margin-left:20px;
  883. }
  884. </style>
  885. <style>
  886. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  887. font-size: 12px;
  888. }
  889. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  890. background: #6fb5fa;
  891. }
  892. .el-autocomplete-suggestion{
  893. width: 400px !important;
  894. }
  895. </style>