血透系统PC前端

cancelStockOrderAdd.vue 14KB

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