血透系统PC前端

stockInOrderAdd.vue 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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 :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> : </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: '/stock/in', name: '入库单' },
  186. { path: '/stock/in/add', 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.isVisibility = false
  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.push(tempForm)
  310. }
  311. }
  312. }
  313. this.currentIndex = -1
  314. }, cancle: function() {
  315. this.isVisibility = false
  316. }, GetAllGoodType: function() {
  317. GetAllGoodType().then(response => {
  318. if (response.data.state == 0) {
  319. this.$message.error(response.data.msg)
  320. return false
  321. } else {
  322. for (let i = 0; i < response.data.data.goodType.length; i++) {
  323. this.propForm.goodType.push(response.data.data.goodType[i])
  324. }
  325. }
  326. })
  327. }, GetAllGoodInfo: function() {
  328. GetAllGoodInfo().then(response => {
  329. if (response.data.state == 0) {
  330. this.$message.error(response.data.msg)
  331. return false
  332. } else {
  333. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  334. this.propForm.goodInfo.push(response.data.data.goodInfo[i])
  335. }
  336. }
  337. })
  338. }, GetConfigInfo: function() {
  339. GetAllConfig().then(response => {
  340. if (response.data.state == 0) {
  341. this.$message.error(response.data.msg)
  342. return false
  343. } else {
  344. this.manufacturer = response.data.data.manufacturer
  345. this.dealer = response.data.data.dealer
  346. this.goodType = response.data.data.goodType
  347. this.goodInfo = response.data.data.goodInfo
  348. }
  349. })
  350. }, typeName: function(good_type_id) {
  351. let name = ''
  352. for (let i = 0; i < this.goodType.length; i++) {
  353. if (this.goodType[i].id == good_type_id) {
  354. name = this.goodType[i].type_name
  355. }
  356. }
  357. return name
  358. }, specificationName: function(good_info_id) {
  359. let name = ''
  360. for (let i = 0; i < this.goodInfo.length; i++) {
  361. if (this.goodInfo[i].id == good_info_id) {
  362. name = this.goodInfo[i].specification_name
  363. }
  364. }
  365. return name
  366. }, handleEdit: function(index, row) {
  367. const tempObj = {}
  368. tempObj['good_type_id'] = 0
  369. tempObj['good_id'] = 0
  370. tempObj['number'] = ''
  371. tempObj['product_date'] = ''
  372. tempObj['expiry_date'] = ''
  373. tempObj['warehousing_count'] = ''
  374. tempObj['price'] = ''
  375. tempObj['remark'] = ''
  376. tempObj['dealer'] = ''
  377. tempObj['manufacturer'] = ''
  378. this.recordInfo.recordData.push(tempObj)
  379. }, handleDelete: function(index, row) {
  380. if( this.recordInfo.recordData.length <= 1){
  381. this.$message.error('只有一条记录的时候无法删除')
  382. return
  383. }else{
  384. this.recordInfo.recordData.splice(index, 1)
  385. }
  386. }, calculate: function(val) {
  387. if (val == 0) {
  388. return ''
  389. }
  390. return Math.round(parseFloat(val) * 100) / 100
  391. }, GetWarehouseInfoByOrdeNumber: function() {
  392. const params = {
  393. 'warehousing_order': sessionStorage.getItem('warehousing_orders')
  394. }
  395. this.recordInfo.recordData = []
  396. getWarehouseInfoByOrdeNumber(params).then(response => {
  397. if (response.data.state != 0) {
  398. for (let i = 0; i < response.data.data.info.length; i++) {
  399. this.recordInfo.recordData.push(response.data.data.info[i])
  400. }
  401. }
  402. })
  403. }, getTime(val, temp) {
  404. if (val != 0) {
  405. return uParseTime(val, temp)
  406. } else {
  407. return ''
  408. }
  409. }, showDialog(index, row) {
  410. this.currentIndex = index
  411. if (this.form.manufacturer == '' || this.form.manufacturer == 0) {
  412. this.$message.error('请先选择厂商')
  413. return
  414. } else {
  415. this.isVisibility = true
  416. const params = {
  417. id: this.form.manufacturer
  418. }
  419. this.propForm.goodType = []
  420. GetAllGoodInfoByID(params).then(response => {
  421. if (response.data.state == 0) {
  422. this.$message.error(response.data.msg)
  423. return false
  424. } else {
  425. if (response.data.data.goodInfo.length == 0) {
  426. this.$message.error('该厂商没商品,请添加商品')
  427. } else {
  428. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  429. this.propForm.goodType.push(response.data.data.goodInfo[i].GoodsType)
  430. }
  431. const obj = {}
  432. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  433. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  434. return cur
  435. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  436. }
  437. }
  438. })
  439. }
  440. }, getSummaries(param) {
  441. const { columns, data } = param
  442. const sums = []
  443. columns.forEach((column, index) => {
  444. if (index === 0) {
  445. sums[index] = '总价'
  446. return
  447. }
  448. const values = data.map(item => Number(item[column.property]))
  449. if (!values.every(value => isNaN(value))) {
  450. sums[index] = values.reduce((prev, curr) => {
  451. const value = Number(curr)
  452. if (!isNaN(value)) {
  453. return prev + curr
  454. } else {
  455. return prev
  456. }
  457. }, 0)
  458. sums[index] += ' 元'
  459. } else {
  460. sums[index] = 'N/A'
  461. }
  462. })
  463. return sums
  464. }, back() {
  465. this.$router.go(-1)
  466. }, submit() {
  467. this.$refs['tableForm'].validate((valid) => {
  468. if (valid) {
  469. if (this.form.manufacturer == 0) {
  470. this.$message.error('厂商不能为空')
  471. return
  472. }
  473. const array = this.recordInfo.recordData
  474. for (let i = 0; i < array.length; i++) {
  475. if (array[i].good_type_id == 0) {
  476. this.$message.error('物品类型不能为空')
  477. return
  478. }
  479. if (array[i].good_id == 0) {
  480. this.$message.error('规格名称不能为空')
  481. return
  482. }
  483. }
  484. const params = {
  485. 'stockIn': this.recordInfo.recordData
  486. }
  487. postWarehouse(params, this.warehousing_time, this.form.manufacturer, this.form.dealer, this.type).then(response => {
  488. if (response.data.state == 0) {
  489. this.$message.error(response.data.msg)
  490. return false
  491. } else {
  492. this.$notify({
  493. title: '成功',
  494. message: '入库成功',
  495. type: 'success',
  496. duration: 2000
  497. })
  498. this.$router.back(-1)
  499. }
  500. })
  501. } else {
  502. return false
  503. }
  504. })
  505. },changeManufacturer(){
  506. this.recordInfo.recordData = []
  507. const tempObj = {}
  508. tempObj['good_type_id'] = 0
  509. tempObj['good_id'] = 0
  510. tempObj['number'] = ''
  511. tempObj['product_date'] = ''
  512. tempObj['expiry_date'] = ''
  513. tempObj['warehousing_count'] = ''
  514. tempObj['price'] = ''
  515. tempObj['remark'] = ''
  516. tempObj['dealer'] = ''
  517. tempObj['manufacturer'] = ''
  518. this.recordInfo.recordData.push(tempObj)
  519. }
  520. },
  521. created() {
  522. var year = new Date().getFullYear()
  523. var month = new Date().getMonth() + 1
  524. var day = new Date().getDate()
  525. if (parseInt(month) < 10) {
  526. month = '0' + month
  527. }
  528. if (parseInt(day) < 10) {
  529. day = '0' + day
  530. }
  531. const endTime = year + '-' + month + '-' + day
  532. this.warehousing_time = endTime
  533. const tempObj = {}
  534. tempObj['good_type_id'] = 0
  535. tempObj['good_id'] = 0
  536. tempObj['number'] = ''
  537. tempObj['product_date'] = ''
  538. tempObj['expiry_date'] = ''
  539. tempObj['warehousing_count'] = ''
  540. tempObj['price'] = ''
  541. tempObj['remark'] = ''
  542. tempObj['dealer'] = ''
  543. tempObj['manufacturer'] = ''
  544. this.recordInfo.recordData.push(tempObj)
  545. this.GetConfigInfo()
  546. this.propForm.goodUnit = this.$store.getters.good_unit
  547. }
  548. }
  549. </script>
  550. <style>
  551. #oictable ::-webkit-scrollbar {
  552. height: 15px;
  553. }
  554. </style>
  555. <style rel="stylesheet/css" lang="scss" scoped>
  556. .information {
  557. border: 1px #dcdfe6 solid;
  558. padding: 30px 20px 30px 20px;
  559. .border {
  560. border-bottom: 1px #dcdfe6 solid;
  561. margin: 0px 0 20px 0;
  562. }
  563. }
  564. .edit_separater {
  565. border-top: 1px solid rgb(233, 233, 233);
  566. margin-top: 15px;
  567. margin-bottom: 15px;
  568. }
  569. </style>
  570. <style>
  571. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  572. font-size: 12px;
  573. }
  574. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  575. background: #6fb5fa;
  576. }
  577. </style>
  578. s