血透系统PC前端

stockOutOrderAdd.vue 16KB

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