血透系统PC前端

stockInOrderEdit.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  20. <el-table id="oictable" :data="recordInfo.recordData" :class="signAndWeighBoxPatients" style="width: 100%" border
  21. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  22. >
  23. <el-table-column align="center" width="200" >
  24. <template slot="header" slot-scope="scope">
  25. <span>商品类型<span style="color: red">*</span></span>
  26. </template>
  27. <template slot-scope="scope">
  28. <el-form-item style="padding-top: 15px">
  29. <el-input placeholder="请输入商品类型" v-model="scope.row.good_type_id"
  30. :value="typeName(scope.row.good_type_id)"
  31. @focus="showDialog(scope.$index, scope.row)"></el-input>
  32. </el-form-item>
  33. </template>
  34. </el-table-column>
  35. <el-table-column align="center" width="200">
  36. <template slot="header" slot-scope="scope">
  37. <span>规格名称<span style="color: red">*</span></span>
  38. </template>
  39. <template slot-scope="scope">
  40. <el-form-item style="padding-top: 15px">
  41. <el-input placeholder="请输入规格名称" v-model="scope.row.good_id"
  42. :value="specificationName(scope.row.good_id)"
  43. @focus="showDialog(scope.$index, scope.row)"></el-input>
  44. </el-form-item>
  45. </template>
  46. </el-table-column>
  47. <el-table-column align="center" width="150">
  48. <template slot="header" slot-scope="scope">
  49. <span>单价<span style="color: red">*</span></span>
  50. </template>
  51. <template slot-scope="scope">
  52. <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  53. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  54. style="padding-top: 17px">
  55. <el-input placeholder="请输入单价" type="number" v-model="scope.row.price"></el-input>
  56. </el-form-item>
  57. </template>
  58. </el-table-column>
  59. <el-table-column align="center" width="180">
  60. <template slot="header" slot-scope="scope">
  61. <span>入库数量<span style="color: red">*</span></span>
  62. </template>
  63. <template slot-scope="scope">
  64. <!--{{scope.row.warehousing_count}}-->
  65. <!--<el-input type="number" v-model="scope.row.warehousing_count" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  66. <el-form-item :prop="'recordData.' + scope.$index + '.warehousing_count'"
  67. :rules='tableRules.warehousing_count' style="padding-top: 17px">
  68. <el-input placeholder="请输入入库数量" type="number" v-model="scope.row.warehousing_count"></el-input>
  69. </el-form-item>
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="总价" align="center" width="150">
  73. <template slot-scope="scope">
  74. {{calculate(scope.row.price*scope.row.warehousing_count)}}
  75. </template>
  76. </el-table-column>
  77. <el-table-column align="center" width="150">
  78. <template slot="header" slot-scope="scope">
  79. <span>批号<span style="color: red">*</span></span>
  80. </template>
  81. <template slot-scope="scope">
  82. <!--<el-input v-model="scope.row.numbers"></el-input>-->
  83. <el-form-item :prop="'recordData.' + scope.$index + '.number'" :rules='tableRules.number'
  84. style="padding-top: 17px">
  85. <el-input placeholder="请输入批号" v-model="scope.row.number"></el-input>
  86. </el-form-item>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="生产日期" width="250" align="center">
  90. <template slot-scope="scope" >
  91. <!--{{scope.row.product_date | parseTime("{y}-{m}-{d}")}}-->
  92. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.product_date"
  93. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  94. value-format="yyyy-MM-dd"></el-date-picker>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="有效日期" width="250" align="center">
  98. <template slot-scope="scope">
  99. <!--{{ scope.row.expiry_date | parseTime("{y}-{m}-{d}")}}-->
  100. <el-date-picker prefix-icon="el-icon-date" style="width: 145px" v-model="scope.row.expiry_date"
  101. type="date" placeholder="选择日期时间" format="yyyy-MM-dd"
  102. value-format="yyyy-MM-dd"></el-date-picker>
  103. </template>
  104. </el-table-column>
  105. <el-table-column label="备注" width="150" align="center">
  106. <template slot-scope="scope">
  107. <el-input v-model="scope.row.remark"></el-input>
  108. </template>
  109. </el-table-column>
  110. <el-table-column label="操作" fixed="right" align="center" width="150">
  111. <template slot-scope="scope">
  112. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  113. <el-button
  114. size="mini"
  115. type="primary"
  116. icon="el-icon-circle-plus-outline"
  117. @click="handleEdit(scope.$index, scope.row)">
  118. </el-button>
  119. </el-tooltip>
  120. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  121. <el-button
  122. size="mini"
  123. type="danger"
  124. icon="el-icon-delete"
  125. @click="handleDelete(scope.$index, scope.row)">
  126. </el-button>
  127. </el-tooltip>
  128. </template>
  129. </el-table-column>
  130. </el-table>
  131. </el-form>
  132. </div>
  133. </div>
  134. </template>
  135. <script>
  136. import stockInDialog from './Dialog/stockInDialog'
  137. import { uParseTime } from '@/utils/tools'
  138. import {
  139. GetAllConfig,
  140. getWarehouseInfoList,
  141. GetAllGoodInfoByID,
  142. getWarehouseInfoByOrdeNumber,
  143. modifyWarehouseInfo,
  144. deleteWarehouseInfo,
  145. DeleteWarehouseInfoItem,
  146. EditWarehouse
  147. } from '@/api/stock'
  148. import BreadCrumb from '../components/bread-crumb'
  149. export default {
  150. components: { BreadCrumb, stockInDialog },
  151. name: 'stockIn',
  152. data() {
  153. var checkGoodId = (rule, value, callback) => {
  154. setTimeout(() => {
  155. if (value == '' || value == 0) {
  156. return callback(new Error('规格名称不能为空'))
  157. }
  158. }, 2000)
  159. }
  160. return {
  161. crumbs: [
  162. { path: false, name: '库存管理' },
  163. { path: '/stock/in', name: '入库单' },
  164. { path: '/stock/in/detail', name: '编辑入库单' }
  165. ],
  166. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  167. warehousing_time: '',
  168. adminUserOptions: null,
  169. currentIndex: 0,
  170. recordInfo: {
  171. recordData: [],
  172. stock_in_code: '',
  173. current_index: ''
  174. },
  175. tableRules: {
  176. price: [
  177. { required: true, message: '单价不能为空', trigger: 'blur' }
  178. ],
  179. warehousing_count: [
  180. { required: true, message: '数量不能为空', trigge: 'blur' }
  181. ],
  182. number: [
  183. { required: true, message: '批号不能为空', trigge: 'blur' }
  184. ],
  185. good_id: [
  186. { validator: checkGoodId, trigger: 'blur' }
  187. ]
  188. },
  189. ruleForm: {
  190. manufacturer: [
  191. { required: true, message: '请选择厂商', trigger: 'change' }
  192. ]
  193. },
  194. total: '',
  195. product_date: '',
  196. expiry_date: '',
  197. numbers: '',
  198. // prop
  199. isVisibility: false,
  200. propForm: {
  201. goodType: [],
  202. goodInfo: [],
  203. goodUnit: [],
  204. title: '入库',
  205. isCreated: 1
  206. },
  207. form: {
  208. manufacturer: '',
  209. dealer: ''
  210. },
  211. warehouse: {},
  212. manufacturer: [],
  213. dealer: [],
  214. goodType: []
  215. }
  216. },
  217. methods: {
  218. comfirm: function(val) {
  219. this.$refs.dialog.hide()
  220. if (val.selectedGoodInfo.length > 0) {
  221. for (let i = val.selectedGoodInfo.length - 1; ;i--) {
  222. if (i == 0) {
  223. this.recordInfo.recordData[this.currentIndex].good_type_id = val.goodTypeId
  224. this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
  225. } else {
  226. const tempForm = {}
  227. tempForm['id'] = 0
  228. tempForm['good_type_id'] = val.goodTypeId
  229. tempForm['good_id'] = val.selectedGoodInfo[i].id
  230. tempForm['number'] = ''
  231. tempForm['product_date'] = ''
  232. tempForm['expiry_date'] = ''
  233. tempForm['warehousing_count'] = ''
  234. tempForm['price'] = ''
  235. tempForm['remark'] = ''
  236. tempForm['dealer'] = ''
  237. tempForm['manufacturer'] = ''
  238. this.recordInfo.recordData.splice(this.currentIndex+1, 0, tempForm);
  239. }
  240. }
  241. }
  242. this.currentIndex = -1
  243. }, cancle: function() {
  244. this.$refs.dialog.hide()
  245. }, GetConfigInfo: function() {
  246. GetAllConfig().then(response => {
  247. if (response.data.state == 0) {
  248. this.$message.error(response.data.msg)
  249. return false
  250. } else {
  251. this.manufacturer = response.data.data.manufacturer
  252. this.dealer = response.data.data.dealer
  253. this.goodType = response.data.data.goodType
  254. this.goodInfo = response.data.data.goodInfo
  255. }
  256. })
  257. }, typeName: function(good_type_id) {
  258. let name = ''
  259. for (let i = 0; i < this.goodType.length; i++) {
  260. if (this.goodType[i].id == good_type_id) {
  261. name = this.goodType[i].type_name
  262. }
  263. }
  264. return name
  265. }, specificationName: function(good_info_id) {
  266. let name = ''
  267. for (let i = 0; i < this.goodInfo.length; i++) {
  268. if (this.goodInfo[i].id == good_info_id) {
  269. name = this.goodInfo[i].specification_name
  270. }
  271. }
  272. return name
  273. }, handleEdit: function(index, row) {
  274. const tempObj = {}
  275. tempObj['id'] = 0
  276. tempObj['good_type_id'] = 0
  277. tempObj['good_id'] = 0
  278. tempObj['number'] = ''
  279. tempObj['product_date'] = ''
  280. tempObj['expiry_date'] = ''
  281. tempObj['warehousing_count'] = ''
  282. tempObj['price'] = ''
  283. tempObj['remark'] = ''
  284. tempObj['dealer'] = ''
  285. tempObj['manufacturer'] = ''
  286. this.recordInfo.recordData.push(tempObj)
  287. }, handleDelete: function(index, row) {
  288. if (row.id == 0) {
  289. this.recordInfo.recordData.splice(index, 1)
  290. } else {
  291. const params = {
  292. id: row.id
  293. }
  294. this.$confirm('确认删除该入库商品信息记录?', '删除入库商品信息记录', {
  295. confirmButtonText: '确定',
  296. cancelButtonText: '取消',
  297. type: 'warning'
  298. }).then(() => {
  299. DeleteWarehouseInfoItem(params).then(response => {
  300. if (response.data.state == 0) {
  301. this.$message.error(response.data.msg)
  302. return false
  303. } else {
  304. this.$message.success("删除成功")
  305. this.recordInfo.recordData.splice(index, 1)
  306. }
  307. })
  308. }).catch(() => {
  309. })
  310. }
  311. }, calculate: function(val) {
  312. if (val == 0) {
  313. return ''
  314. }
  315. return Math.round(parseFloat(val) * 100) / 100
  316. }, getTime(val, temp) {
  317. if (val != 0) {
  318. return uParseTime(val, temp)
  319. } else {
  320. return ''
  321. }
  322. }, showDialog(index, row) {
  323. this.currentIndex = index
  324. if (this.form.manufacturer == '' || this.form.manufacturer == 0) {
  325. this.$message.error('请先选择厂商')
  326. return
  327. } else {
  328. this.isVisibility = true
  329. const params = {
  330. id: this.form.manufacturer
  331. }
  332. this.propForm.goodType = []
  333. GetAllGoodInfoByID(params).then(response => {
  334. if (response.data.state == 0) {
  335. this.$message.error(response.data.msg)
  336. return false
  337. } else {
  338. if (response.data.data.goodInfo.length == 0) {
  339. this.$message.error('该厂商没商品,请添加商品')
  340. } else {
  341. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  342. this.propForm.goodType.push(response.data.data.goodInfo[i].GoodsType)
  343. }
  344. const obj = {}
  345. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  346. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  347. return cur
  348. }, []) // 设置cur默认类型为数组,并且初始值为空的数组
  349. this.$refs.dialog.show()
  350. }
  351. }
  352. })
  353. }
  354. }, back() {
  355. this.$router.go(-1)
  356. }, submit() {
  357. this.$refs['tableForm'].validate((valid) => {
  358. if (valid) {
  359. const array = this.recordInfo.recordData
  360. for (let i = 0; i < array.length; i++) {
  361. if (array[i].good_type_id == 0) {
  362. this.$message.error('商品类型不能为空')
  363. return
  364. }
  365. if (array[i].good_id == 0) {
  366. this.$message.error('规格名称不能为空')
  367. return
  368. }
  369. }
  370. const params = {
  371. 'stockIn': this.recordInfo.recordData
  372. }
  373. EditWarehouse(params, this.warehousing_time, this.$route.query.id,this.$route.query.type).then(response => {
  374. if (response.data.state == 0) {
  375. this.$message.error(response.data.msg)
  376. return false
  377. } else {
  378. this.$message.success("入库成功")
  379. this.$router.back(-1)
  380. }
  381. })
  382. } else {
  383. return false
  384. }
  385. })
  386. }, GetOrderDetail: function(order_id) {
  387. const params = {
  388. 'id': order_id
  389. }
  390. getWarehouseInfoList(params).then(response => {
  391. if (response.data.state == 0) {
  392. this.$message.error(response.data.msg)
  393. return false
  394. } else {
  395. for (let i = 0; i < response.data.data.info.length; i++) {
  396. response.data.data.info[i].product_date = this.getTime(response.data.data.info[i].product_date, '{y}-{m}-{d}')
  397. response.data.data.info[i].expiry_date = this.getTime(response.data.data.info[i].expiry_date, '{y}-{m}-{d}')
  398. response.data.data.info[i].price = response.data.data.info[i].price.toString()
  399. response.data.data.info[i].warehousing_count = response.data.data.info[i].warehousing_count.toString()
  400. this.recordInfo.recordData.push(response.data.data.info[i])
  401. }
  402. this.warehouse = response.data.data.warehousing
  403. this.form.manufacturer = this.warehouse.manufacturer
  404. this.form.dealer = this.warehouse.dealer
  405. this.warehousing_time = this.getTime(this.warehouse.warehousing_time, '{y}-{m}-{d}')
  406. if(this.recordInfo.recordData.length == 0){
  407. const tempObj = {}
  408. tempObj['id'] = 0
  409. tempObj['good_type_id'] = 0
  410. tempObj['good_id'] = 0
  411. tempObj['number'] = ''
  412. tempObj['product_date'] = ''
  413. tempObj['expiry_date'] = ''
  414. tempObj['warehousing_count'] = ''
  415. tempObj['price'] = ''
  416. tempObj['remark'] = ''
  417. tempObj['dealer'] = ''
  418. tempObj['manufacturer'] = ''
  419. this.recordInfo.recordData.push(tempObj)
  420. }
  421. }
  422. })
  423. }
  424. },
  425. created() {
  426. this.GetConfigInfo()
  427. this.propForm.goodUnit = this.$store.getters.good_unit
  428. const order_id = this.$route.query.id
  429. this.GetOrderDetail(order_id)
  430. }
  431. }
  432. </script>
  433. <style>
  434. #oictable ::-webkit-scrollbar {
  435. height: 15px;
  436. }
  437. </style>
  438. <style rel="stylesheet/css" lang="scss" scoped>
  439. .information {
  440. border: 1px #dcdfe6 solid;
  441. padding: 30px 20px 30px 20px;
  442. .border {
  443. border-bottom: 1px #dcdfe6 solid;
  444. margin: 0px 0 20px 0;
  445. }
  446. }
  447. .edit_separater {
  448. border-top: 1px solid rgb(233, 233, 233);
  449. margin-top: 15px;
  450. margin-bottom: 15px;
  451. }
  452. </style>
  453. <style>
  454. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  455. font-size: 12px;
  456. }
  457. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  458. background: #6fb5fa;
  459. }
  460. </style>