血透系统PC前端

stockOutOrderAdd.vue 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. <div class="cell clearfix">
  22. <label class="title"><span class="name">厂商<span style="color: red;margin-left: -15px">*</span></span> : </label>
  23. <el-select size="small" 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 size="small" 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: false, name: '出库单' },
  141. { path: false, 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. warehouseInfoList:[],
  175. manufacturer: [],
  176. dealer: [],
  177. goodType: []
  178. }
  179. },
  180. methods: {
  181. comfirm: function(val) {
  182. this.$refs.dialog.hide()
  183. if (val.selectedGoodInfo.length > 0) {
  184. for (let i = val.selectedGoodInfo.length - 1; ;i--) {
  185. if (i == 0) {
  186. this.recordInfo.recordData[this.currentIndex].good_type_id = val.goodTypeId
  187. this.recordInfo.recordData[this.currentIndex].good_id = val.selectedGoodInfo[i].id
  188. } else {
  189. const tempForm = {}
  190. tempForm['good_type_id'] = val.goodTypeId
  191. tempForm['good_id'] = val.selectedGoodInfo[i].id
  192. tempForm['count'] = ''
  193. tempForm['price'] = ''
  194. tempForm['remark'] = ''
  195. this.recordInfo.recordData.splice(this.currentIndex + 1, 0, tempForm)
  196. }
  197. }
  198. }
  199. this.currentIndex = -1
  200. }, cancle: function() {
  201. this.$refs.dialog.hide()
  202. }, GetConfigInfo: function() {
  203. const params = {
  204. type: this.$route.query.type
  205. }
  206. getSalesReturnConfig(params).then(response => {
  207. if (response.data.state == 0) {
  208. this.$message.error(response.data.msg)
  209. return false
  210. } else {
  211. var warehouseList = response.data.data.warehouseList
  212. var warehouseInfoList = response.data.data.warehouseInfoList
  213. this.warehouseInfoList = response.data.data.warehouseInfoList
  214. for (let i = 0; i < warehouseList.length; i++) {
  215. if (warehouseList[i].Manufacturer.id > 0) {
  216. this.manufacturer.push(warehouseList[i].Manufacturer)
  217. }
  218. if (warehouseList[i].Dealer.id > 0) {
  219. this.dealer.push(warehouseList[i].Dealer)
  220. }
  221. }
  222. for (let i = 0; i < warehouseInfoList.length; i++) {
  223. this.propForm.goodInfo.push(warehouseInfoList[i].GoodInfo)
  224. }
  225. const obj = {}
  226. const obj2 = {}
  227. const obj4 = {}
  228. // 去重复
  229. this.manufacturer = this.manufacturer.reduce((cur, next) => {
  230. obj[next.id] ? '' : obj[next.id] = true && cur.push(next)
  231. return cur
  232. }, [])
  233. // 去重复
  234. this.dealer = this.dealer.reduce((cur, next) => {
  235. obj2[next.id] ? '' : obj2[next.id] = true && cur.push(next)
  236. return cur
  237. }, [])
  238. this.propForm.goodInfo = this.propForm.goodInfo.reduce((cur, next) => {
  239. obj4[next.id] ? '' : obj4[next.id] = true && cur.push(next)
  240. return cur
  241. }, [])
  242. }
  243. })
  244. }, typeName: function(good_type_id) {
  245. let name = ''
  246. for (let i = 0; i < this.propForm.goodType.length; i++) {
  247. if (this.propForm.goodType[i].id == good_type_id) {
  248. name = this.propForm.goodType[i].type_name
  249. }
  250. }
  251. return name
  252. }, specificationName: function(good_info_id) {
  253. let name = ''
  254. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  255. if (this.propForm.goodInfo[i].id == good_info_id) {
  256. name = this.propForm.goodInfo[i].specification_name
  257. }
  258. }
  259. return name
  260. }, handleEdit: function(index, row) {
  261. const tempObj = {}
  262. tempObj['good_type_id'] = 0
  263. tempObj['good_id'] = 0
  264. tempObj['count'] = ''
  265. tempObj['price'] = ''
  266. tempObj['remark'] = ''
  267. this.recordInfo.recordData.push(tempObj)
  268. }, handleDelete: function(index, row) {
  269. if (this.recordInfo.recordData.length <= 1) {
  270. this.$message.error('只有一条记录的时候无法删除')
  271. return
  272. } else {
  273. this.recordInfo.recordData.splice(index, 1)
  274. }
  275. }, calculate: function(val) {
  276. if (isNaN(val)) {
  277. return ''
  278. }
  279. if (val == 0) {
  280. return ''
  281. }
  282. return Math.round(parseFloat(val) * 100) / 100
  283. }, getTime(val, temp) {
  284. if (val != 0) {
  285. return uParseTime(val, temp)
  286. } else {
  287. return ''
  288. }
  289. }, showDialog(index, row) {
  290. this.currentIndex = index
  291. if (this.form.manufacturer == '' || this.form.manufacturer == 0) {
  292. this.$message.error('请先选择厂商')
  293. return
  294. } else {
  295. this.$refs.dialog.show()
  296. for (let i = 0; i < this.warehouseInfoList.length; i++) {
  297. if (this.warehouseInfoList[i].manufacturer == this.form.manufacturer) {
  298. this.propForm.goodType.push(this.warehouseInfoList[i].GoodInfo.GoodsType)
  299. }
  300. }
  301. const obj3 = {}
  302. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  303. obj3[next.id] ? '' : obj3[next.id] = true && cur.push(next)
  304. return cur
  305. }, [])
  306. }
  307. }, back() {
  308. this.$router.go(-1)
  309. }, submit() {
  310. this.$refs['tableForm'].validate((valid) => {
  311. if (valid) {
  312. if (this.form.manufacturer == 0) {
  313. this.$message.error('厂商不能为空')
  314. return
  315. }
  316. const array = this.recordInfo.recordData
  317. let total = 0
  318. for (let i = 0; i < array.length; i++) {
  319. if (array[i].good_type_id == 0) {
  320. this.$message.error('商品类型不能为空')
  321. return
  322. }
  323. if (array[i].good_id == 0) {
  324. this.$message.error('规格名称不能为空')
  325. return
  326. }
  327. total = total + array[i].price * array[i].return_count
  328. }
  329. const params = {
  330. 'stockOut': this.recordInfo.recordData
  331. }
  332. console.log(this.form.dealer)
  333. postWarehouseOut(params, this.warehouse_out_time, this.form.dealer, this.form.manufacturer, this.type).then(response => {
  334. if (response.data.state == 0) {
  335. this.$message.error(response.data.msg)
  336. return false
  337. } else {
  338. this.$message.success('退货成功')
  339. this.recordInfo.recordData = []
  340. this.$router.back(-1)
  341. }
  342. })
  343. } else {
  344. return false
  345. }
  346. })
  347. }, changeManufacturer() {
  348. this.recordInfo.recordData = []
  349. const tempObj = {}
  350. tempObj['good_type_id'] = 0
  351. tempObj['good_id'] = 0
  352. tempObj['return_count'] = 0
  353. tempObj['price'] = ''
  354. tempObj['remark'] = ''
  355. this.recordInfo.recordData.push(tempObj)
  356. }
  357. },
  358. created() {
  359. var nowDate = new Date()
  360. var nowYear = nowDate.getFullYear()
  361. var nowMonth = nowDate.getMonth() + 1
  362. var nowDay = nowDate.getDate()
  363. this.warehouse_out_time =
  364. nowYear +
  365. '-' +
  366. (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
  367. '-' +
  368. (nowDay < 10 ? '0' + nowDay : nowDay)
  369. const tempObj = {}
  370. tempObj['good_type_id'] = 0
  371. tempObj['good_id'] = 0
  372. tempObj['return_count'] = 0
  373. tempObj['price'] = ''
  374. tempObj['remark'] = ''
  375. this.recordInfo.recordData.push(tempObj)
  376. this.GetConfigInfo()
  377. this.propForm.goodUnit = this.$store.getters.good_unit
  378. }
  379. }
  380. </script>
  381. <style rel="stylesheet/css" lang="scss" scoped>
  382. .information {
  383. border: 1px #dcdfe6 solid;
  384. padding: 30px 20px 30px 20px;
  385. .border {
  386. border-bottom: 1px #dcdfe6 solid;
  387. margin: 0px 0 20px 0;
  388. }
  389. }
  390. .edit_separater {
  391. border-top: 1px solid rgb(233, 233, 233);
  392. margin-top: 15px;
  393. margin-bottom: 15px;
  394. }
  395. </style>
  396. <style>
  397. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  398. font-size: 12px;
  399. }
  400. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  401. background: #6fb5fa;
  402. }
  403. </style>