血透系统PC前端

stockInOrderAdd.vue 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb :crumbs='crumbs'></bread-crumb>
  5. <div style="float:right;">
  6. <el-button size="small" @click="back()" class="filter-item" >取 消</el-button>
  7. <el-button size="small" type="primary" @click="submit()" class="filter-item" >保 存</el-button>
  8. </div>
  9. </div>
  10. <div class="app-container">
  11. <stock-in-dialog ref="dialog" :propForm="propForm"
  12. :visibility="isVisibility"
  13. v-on:dialog-comfirm="comfirm"
  14. v-on:dialog-cancle="cancle"></stock-in-dialog>
  15. <div class="cell clearfix">
  16. <label class="title"><span class="name">入库时间</span> : </label>
  17. <el-date-picker v-model="warehousing_time" prefix-icon="el-icon-date" :editable="false" style="width: 196px;" type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd" value-format="yyyy-MM-dd" > </el-date-picker>
  18. </div>
  19. <div class="cell clearfix">
  20. <label class="title"><span class="name">厂商<span style="color: red;margin-left: -15px">*</span></span> : </label>
  21. <el-select v-model="form.manufacturer" clearable placeholder="请选择厂商" @change="changeManufacturer()" >
  22. <el-option
  23. v-for="(option, index) in manufacturer"
  24. :key="index"
  25. :label="option.manufacturer_name"
  26. :value="option.id">
  27. </el-option>
  28. </el-select>
  29. </div>
  30. <div class="cell clearfix">
  31. <label class="title"><span class="name">经销商</span> : </label>
  32. <el-select v-model="form.dealer" clearable placeholder="请选择经销商" >
  33. <el-option
  34. v-for="(option, index) in dealer"
  35. :key="index"
  36. :label="option.dealer_name"
  37. :value="option.id">
  38. </el-option>
  39. </el-select>
  40. </div>
  41. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  42. <el-table id="oictable" :data="recordInfo.recordData" :class="signAndWeighBoxPatients" border style="width: 100%"
  43. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  44. >
  45. <el-table-column align="center" width="200">
  46. <template slot="header" slot-scope="scope">
  47. <span>商品类型<span style="color: red">*</span></span>
  48. </template>
  49. <template slot-scope="scope">
  50. <el-form-item style="padding-top: 15px">
  51. <el-input placeholder="请输入商品类型" v-model="scope.row.good_type_id"
  52. :value="typeName(scope.row.good_type_id)"
  53. @focus="showDialog(scope.$index, scope.row)"></el-input>
  54. </el-form-item>
  55. </template>
  56. </el-table-column>
  57. <el-table-column align="center" width="200">
  58. <template slot="header" slot-scope="scope">
  59. <span>规格名称<span style="color: red">*</span></span>
  60. </template>
  61. <template slot-scope="scope">
  62. <el-form-item style="padding-top: 15px">
  63. <el-input placeholder="请输入规格名称" v-model="scope.row.good_id"
  64. :value="specificationName(scope.row.good_id)"
  65. @focus="showDialog(scope.$index, scope.row)"></el-input>
  66. </el-form-item>
  67. </template>
  68. </el-table-column>
  69. <el-table-column align="center" width="150">
  70. <template slot="header" slot-scope="scope">
  71. <span>单价<span style="color: red">*</span></span>
  72. </template>
  73. <template slot-scope="scope">
  74. <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  75. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  76. style="padding-top: 17px">
  77. <el-input placeholder="请输入单价" type="number" v-model="scope.row.price"></el-input>
  78. </el-form-item>
  79. </template>
  80. </el-table-column>
  81. <el-table-column align="center" width="180">
  82. <template slot="header" slot-scope="scope">
  83. <span>入库数量<span style="color: red">*</span></span>
  84. </template>
  85. <template slot-scope="scope">
  86. <!--{{scope.row.warehousing_count}}-->
  87. <!--<el-input type="number" v-model="scope.row.warehousing_count" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  88. <el-form-item :prop="'recordData.' + scope.$index + '.warehousing_count'"
  89. :rules='tableRules.warehousing_count' style="padding-top: 17px">
  90. <el-input placeholder="请输入入库数量" type="number" v-model="scope.row.warehousing_count"></el-input>
  91. </el-form-item>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="总价" align="center" width="150">
  95. <template slot-scope="scope">
  96. {{calculate(scope.row.price*scope.row.warehousing_count)}}
  97. </template>
  98. </el-table-column>
  99. <el-table-column align="center" width="150">
  100. <template slot="header" slot-scope="scope">
  101. <span>批号<span style="color: red">*</span></span>
  102. </template>
  103. <template slot-scope="scope">
  104. <!--<el-input v-model="scope.row.numbers"></el-input>-->
  105. <el-form-item :prop="'recordData.' + scope.$index + '.number'" :rules='tableRules.number'
  106. style="padding-top: 17px">
  107. <el-input placeholder="请输入批号" v-model="scope.row.number"></el-input>
  108. </el-form-item>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="生产日期" align="center" width="250">
  112. <template slot-scope="scope">
  113. <!--{{scope.row.product_date | parseTime("{y}-{m}-{d}")}}-->
  114. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.product_date"
  115. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  116. value-format="yyyy-MM-dd"></el-date-picker>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="有效日期" align="center" width="250">
  120. <template slot-scope="scope">
  121. <!--{{ scope.row.expiry_date | parseTime("{y}-{m}-{d}")}}-->
  122. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.expiry_date"
  123. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  124. value-format="yyyy-MM-dd"></el-date-picker>
  125. </template>
  126. </el-table-column>
  127. <el-table-column label="备注" align="center" width="150">
  128. <template slot-scope="scope">
  129. <el-input placeholder="请输入备注" v-model="scope.row.remark"></el-input>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="操作" align="center" fixed="right" width="150">
  133. <template slot-scope="scope" >
  134. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  135. <el-button
  136. size="mini"
  137. type="primary"
  138. icon="el-icon-circle-plus-outline"
  139. @click="handleEdit(scope.$index, scope.row)">
  140. </el-button>
  141. </el-tooltip>
  142. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  143. <el-button
  144. size="mini"
  145. type="danger"
  146. icon="el-icon-delete"
  147. @click="handleDelete(scope.$index, scope.row)">
  148. </el-button>
  149. </el-tooltip>
  150. </template>
  151. </el-table-column>
  152. </el-table>
  153. </el-form>
  154. </div>
  155. </div>
  156. </template>
  157. <script>
  158. import stockInDialog from './Dialog/stockInDialog'
  159. import { uParseTime } from '@/utils/tools'
  160. import {
  161. deleteWarehouseInfo,
  162. GetAllConfig,
  163. GetAllGoodInfo,
  164. GetAllGoodInfoByID,
  165. GetAllGoodType,
  166. getWarehouseInfoByOrdeNumber,
  167. modifyWarehouseInfo,
  168. postWarehouse
  169. } from '@/api/stock'
  170. import BreadCrumb from '../components/bread-crumb'
  171. export default {
  172. components: { BreadCrumb, stockInDialog },
  173. name: 'stockIn',
  174. data() {
  175. var checkGoodId = (rule, value, callback) => {
  176. setTimeout(() => {
  177. if (value == '' || value == 0) {
  178. return callback(new Error('规格名称不能为空'))
  179. }
  180. }, 2000)
  181. }
  182. return {
  183. crumbs: [
  184. { path: false, name: '库存管理' },
  185. { path: false, name: '入库单' },
  186. { path: false, name: '新增入库单' }
  187. ],
  188. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  189. warehousing_time: '',
  190. adminUserOptions: null,
  191. currentIndex: 0,
  192. recordInfo: {
  193. recordData: [],
  194. stock_in_code: '',
  195. current_index: ''
  196. },
  197. tableRules: {
  198. price: [
  199. { required: true, message: '单价不能为空', trigger: 'blur' }
  200. ],
  201. warehousing_count: [
  202. { required: true, message: '数量不能为空', trigge: 'blur' }
  203. ],
  204. number: [
  205. { required: true, message: '批号不能为空', trigge: 'blur' }
  206. ],
  207. good_id: [
  208. { validator: checkGoodId, trigger: 'blur' }
  209. ]
  210. },
  211. ruleForm: {
  212. manufacturer: [
  213. { required: true, message: '请选择厂商', trigger: 'change' }
  214. ]
  215. },
  216. type: this.$route.query.type,
  217. total: '',
  218. product_date: '',
  219. expiry_date: '',
  220. numbers: '',
  221. // prop
  222. isVisibility: false,
  223. propForm: {
  224. goodType: [],
  225. goodInfo: [],
  226. goodUnit: [],
  227. title: '入库',
  228. formValue: {
  229. good_type_id: '',
  230. good_id: '',
  231. number: '',
  232. product_date: '',
  233. expiry_date: '',
  234. warehousing_count: '',
  235. price: '',
  236. remark: '',
  237. dealer: '',
  238. manufacturer: ''
  239. },
  240. isCreated: 1
  241. },
  242. goodInfo: {
  243. loading: false,
  244. goodTypeData: [],
  245. type_code: ''
  246. },
  247. form: {
  248. manufacturer: '',
  249. dealer: ''
  250. },
  251. formValue: {
  252. good_type_id: '',
  253. good_id: '',
  254. number: '',
  255. product_date: '',
  256. expiry_date: '',
  257. warehousing_count: '',
  258. price: '',
  259. remark: '',
  260. dealer: '',
  261. manufacturer: ''
  262. },
  263. manufacturer: [],
  264. dealer: [],
  265. goodType: []
  266. }
  267. },
  268. methods: {
  269. handleSave: function() {
  270. if (this.recordInfo.recordData.length <= 0) {
  271. this.$message.error('请添加入库信息')
  272. return
  273. }
  274. sessionStorage.removeItem('warehousing_orders')
  275. this.$router.back(-1)
  276. }, handleCancle: function() {
  277. this.$confirm('是否放弃编辑返回上一页?', '放弃编辑', {
  278. confirmButtonText: '确定',
  279. cancelButtonText: '取消',
  280. type: 'warning'
  281. }).then(() => {
  282. sessionStorage.removeItem('warehousing_orders')
  283. this.$router.back(-1)
  284. }).catch(() => {
  285. })
  286. }, handleCreate: function() {
  287. this.propForm.formValue = {}
  288. this.propForm.isCreated = 1
  289. this.isVisibility = true
  290. }, comfirm: function(val) {
  291. this.$refs.dialog.hide()
  292. if (val.selectedGoodInfo.length > 0) {
  293. for (let i = val.selectedGoodInfo.length - 1; ; i--) {
  294. if (i == 0) {
  295. this.recordInfo.recordData[this.currentIndex].good_type_id = val.goodTypeId
  296. this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
  297. } else {
  298. const tempForm = {}
  299. tempForm['good_type_id'] = val.goodTypeId
  300. tempForm['good_id'] = val.selectedGoodInfo[i].id
  301. tempForm['number'] = ''
  302. tempForm['product_date'] = ''
  303. tempForm['expiry_date'] = ''
  304. tempForm['warehousing_count'] = ''
  305. tempForm['price'] = ''
  306. tempForm['remark'] = ''
  307. tempForm['dealer'] = ''
  308. tempForm['manufacturer'] = ''
  309. // this.recordInfo.recordData.add(tempForm,this.currentIndex + i)
  310. // this.recordInfo.recordData.push(tempForm)
  311. this.recordInfo.recordData.splice(this.currentIndex+1, 0, tempForm);
  312. }
  313. }
  314. }
  315. this.currentIndex = -1
  316. }, cancle: function() {
  317. this.$refs.dialog.hide()
  318. }, GetAllGoodType: function() {
  319. GetAllGoodType().then(response => {
  320. if (response.data.state == 0) {
  321. this.$message.error(response.data.msg)
  322. return false
  323. } else {
  324. for (let i = 0; i < response.data.data.goodType.length; i++) {
  325. this.propForm.goodType.push(response.data.data.goodType[i])
  326. }
  327. }
  328. })
  329. }, GetAllGoodInfo: function() {
  330. GetAllGoodInfo().then(response => {
  331. if (response.data.state == 0) {
  332. this.$message.error(response.data.msg)
  333. return false
  334. } else {
  335. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  336. this.propForm.goodInfo.push(response.data.data.goodInfo[i])
  337. }
  338. }
  339. })
  340. }, GetConfigInfo: function() {
  341. GetAllConfig().then(response => {
  342. if (response.data.state == 0) {
  343. this.$message.error(response.data.msg)
  344. return false
  345. } else {
  346. this.manufacturer = response.data.data.manufacturer
  347. this.dealer = response.data.data.dealer
  348. this.goodType = response.data.data.goodType
  349. this.goodInfo = response.data.data.goodInfo
  350. }
  351. })
  352. }, typeName: function(good_type_id) {
  353. let name = ''
  354. for (let i = 0; i < this.goodType.length; i++) {
  355. if (this.goodType[i].id == good_type_id) {
  356. name = this.goodType[i].type_name
  357. }
  358. }
  359. return name
  360. }, specificationName: function(good_info_id) {
  361. let name = ''
  362. for (let i = 0; i < this.goodInfo.length; i++) {
  363. if (this.goodInfo[i].id == good_info_id) {
  364. name = this.goodInfo[i].specification_name
  365. }
  366. }
  367. return name
  368. }, handleEdit: function(index, row) {
  369. const tempObj = {}
  370. tempObj['good_type_id'] = 0
  371. tempObj['good_id'] = 0
  372. tempObj['number'] = ''
  373. tempObj['product_date'] = ''
  374. tempObj['expiry_date'] = ''
  375. tempObj['warehousing_count'] = ''
  376. tempObj['price'] = ''
  377. tempObj['remark'] = ''
  378. tempObj['dealer'] = ''
  379. tempObj['manufacturer'] = ''
  380. this.recordInfo.recordData.push(tempObj)
  381. }, handleDelete: function(index, row) {
  382. if( this.recordInfo.recordData.length <= 1){
  383. this.$message.error('只有一条记录的时候无法删除')
  384. return
  385. }else{
  386. this.recordInfo.recordData.splice(index, 1)
  387. }
  388. }, calculate: function(val) {
  389. if (val == 0) {
  390. return ''
  391. }
  392. return Math.round(parseFloat(val) * 100) / 100
  393. }, GetWarehouseInfoByOrdeNumber: function() {
  394. const params = {
  395. 'warehousing_order': sessionStorage.getItem('warehousing_orders')
  396. }
  397. this.recordInfo.recordData = []
  398. getWarehouseInfoByOrdeNumber(params).then(response => {
  399. if (response.data.state != 0) {
  400. for (let i = 0; i < response.data.data.info.length; i++) {
  401. this.recordInfo.recordData.push(response.data.data.info[i])
  402. }
  403. }
  404. })
  405. }, getTime(val, temp) {
  406. if (val != 0) {
  407. return uParseTime(val, temp)
  408. } else {
  409. return ''
  410. }
  411. }, showDialog(index, row) {
  412. this.currentIndex = index
  413. if (this.form.manufacturer == '' || this.form.manufacturer == 0) {
  414. this.$message.error('请先选择厂商')
  415. return
  416. } else {
  417. // this.isVisibility = true
  418. const params = {
  419. id: this.form.manufacturer
  420. }
  421. this.propForm.goodType = []
  422. GetAllGoodInfoByID(params).then(response => {
  423. if (response.data.state == 0) {
  424. this.$message.error(response.data.msg)
  425. return false
  426. } else {
  427. if (response.data.data.goodInfo.length == 0) {
  428. this.$message.error('该厂商没商品,请添加商品')
  429. } else {
  430. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  431. this.propForm.goodType.push(response.data.data.goodInfo[i].GoodsType)
  432. }
  433. const obj = {}
  434. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  435. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  436. return cur
  437. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  438. this.$refs.dialog.show()
  439. }
  440. }
  441. })
  442. }
  443. }, getSummaries(param) {
  444. const { columns, data } = param
  445. const sums = []
  446. columns.forEach((column, index) => {
  447. if (index === 0) {
  448. sums[index] = '总价'
  449. return
  450. }
  451. const values = data.map(item => Number(item[column.property]))
  452. if (!values.every(value => isNaN(value))) {
  453. sums[index] = values.reduce((prev, curr) => {
  454. const value = Number(curr)
  455. if (!isNaN(value)) {
  456. return prev + curr
  457. } else {
  458. return prev
  459. }
  460. }, 0)
  461. sums[index] += ' 元'
  462. } else {
  463. sums[index] = 'N/A'
  464. }
  465. })
  466. return sums
  467. }, back() {
  468. this.$router.go(-1)
  469. }, submit() {
  470. this.$refs['tableForm'].validate((valid) => {
  471. if (valid) {
  472. if (this.form.manufacturer == 0) {
  473. this.$message.error('厂商不能为空')
  474. return
  475. }
  476. const array = this.recordInfo.recordData
  477. for (let i = 0; i < array.length; i++) {
  478. if (array[i].good_type_id == 0) {
  479. this.$message.error('商品类型不能为空')
  480. return
  481. }
  482. if (array[i].good_id == 0) {
  483. this.$message.error('规格名称不能为空')
  484. return
  485. }
  486. }
  487. const params = {
  488. 'stockIn': this.recordInfo.recordData
  489. }
  490. postWarehouse(params, this.warehousing_time, this.form.manufacturer, this.form.dealer, this.type).then(response => {
  491. if (response.data.state == 0) {
  492. this.$message.error(response.data.msg)
  493. return false
  494. } else {
  495. this.$message.success('入库成功')
  496. this.$router.back(-1)
  497. }
  498. })
  499. } else {
  500. return false
  501. }
  502. })
  503. },changeManufacturer(){
  504. this.recordInfo.recordData = []
  505. const tempObj = {}
  506. tempObj['good_type_id'] = 0
  507. tempObj['good_id'] = 0
  508. tempObj['number'] = ''
  509. tempObj['product_date'] = ''
  510. tempObj['expiry_date'] = ''
  511. tempObj['warehousing_count'] = ''
  512. tempObj['price'] = ''
  513. tempObj['remark'] = ''
  514. tempObj['dealer'] = ''
  515. tempObj['manufacturer'] = ''
  516. this.recordInfo.recordData.push(tempObj)
  517. }
  518. },
  519. created() {
  520. var year = new Date().getFullYear()
  521. var month = new Date().getMonth() + 1
  522. var day = new Date().getDate()
  523. if (parseInt(month) < 10) {
  524. month = '0' + month
  525. }
  526. if (parseInt(day) < 10) {
  527. day = '0' + day
  528. }
  529. const endTime = year + '-' + month + '-' + day
  530. this.warehousing_time = endTime
  531. const tempObj = {}
  532. tempObj['good_type_id'] = 0
  533. tempObj['good_id'] = 0
  534. tempObj['number'] = ''
  535. tempObj['product_date'] = ''
  536. tempObj['expiry_date'] = ''
  537. tempObj['warehousing_count'] = ''
  538. tempObj['price'] = ''
  539. tempObj['remark'] = ''
  540. tempObj['dealer'] = ''
  541. tempObj['manufacturer'] = ''
  542. this.recordInfo.recordData.push(tempObj)
  543. this.GetConfigInfo()
  544. this.propForm.goodUnit = this.$store.getters.good_unit
  545. }
  546. }
  547. </script>
  548. <style>
  549. #oictable ::-webkit-scrollbar {
  550. height: 15px;
  551. }
  552. </style>
  553. <style rel="stylesheet/css" lang="scss" scoped>
  554. .information {
  555. border: 1px #dcdfe6 solid;
  556. padding: 30px 20px 30px 20px;
  557. .border {
  558. border-bottom: 1px #dcdfe6 solid;
  559. margin: 0px 0 20px 0;
  560. }
  561. }
  562. .edit_separater {
  563. border-top: 1px solid rgb(233, 233, 233);
  564. margin-top: 15px;
  565. margin-bottom: 15px;
  566. }
  567. </style>
  568. <style>
  569. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  570. font-size: 12px;
  571. }
  572. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  573. background: #6fb5fa;
  574. }
  575. </style>
  576. s