血透系统PC前端

stockOutOrderEdit.vue 15KB

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