血透系统PC前端

cancelStockOrderAdd.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  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="filter-container">
  16. <div class="cell">
  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> : </label>
  24. <el-select v-model="form.manufacturer" clearable placeholder="请选择厂商" >
  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-remove-outline"
  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: '/stock/return', name: '退库单' },
  122. { path: '/stock/return/add', 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.isVisibility = false
  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.push(tempForm)
  171. }
  172. }
  173. }
  174. this.currentIndex = -1
  175. }, cancle: function() {
  176. this.isVisibility = false
  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. this.recordInfo.recordData.splice(index, 1)
  242. }, calculate: function(val) {
  243. if (val == 0) {
  244. return ''
  245. }
  246. return Math.round(parseFloat(val) * 100) / 100
  247. }, getTime(val, temp) {
  248. if (val != 0) {
  249. return uParseTime(val, temp)
  250. } else {
  251. return ''
  252. }
  253. }, showDialog(index, row) {
  254. this.currentIndex = index
  255. if (this.form.manufacturer == '' || this.form.manufacturer == 0) {
  256. this.$message.error('请先选择厂商')
  257. return
  258. } else {
  259. this.isVisibility = true
  260. console.log(this.form.manufacturer)
  261. for (let i = 0; i < this.propForm.goodInfo.length; i++) {
  262. if (this.propForm.goodInfo[i].manufacturer == this.form.manufacturer) {
  263. this.propForm.goodType.push(this.propForm.goodInfo[i].GoodsType)
  264. }
  265. }
  266. const obj3 = {}
  267. this.propForm.goodType = this.propForm.goodType.reduce((cur, next) => {
  268. obj3[next.id] ? '' : obj3[next.id] = true && cur.push(next)
  269. return cur
  270. }, [])
  271. }
  272. }, back() {
  273. this.$router.go(-1)
  274. }, submit() {
  275. this.$refs['tableForm'].validate((valid) => {
  276. if (valid) {
  277. if (this.form.manufacturer == 0) {
  278. this.$message.error('厂商不能为空')
  279. return
  280. }
  281. const array = this.recordInfo.recordData
  282. let total = 0
  283. for (let i = 0; i < array.length; i++) {
  284. if (array[i].good_type_id == 0) {
  285. this.$message.error('物品类型不能为空')
  286. return
  287. }
  288. if (array[i].good_id == 0) {
  289. this.$message.error('规格名称不能为空')
  290. return
  291. }
  292. total = total + array[i].price * array[i].return_count
  293. }
  294. const params = {
  295. 'cancelStock': this.recordInfo.recordData
  296. }
  297. postCancelStock(params, this.return_time, this.form.manufacturer, this.form.dealer, this.type).then(response => {
  298. if (response.data.state == 0) {
  299. this.$message.error(response.data.msg)
  300. return false
  301. } else {
  302. this.$notify({
  303. title: '成功',
  304. message: '退货成功',
  305. type: 'success',
  306. duration: 2000
  307. })
  308. this.recordInfo.recordData = []
  309. this.$router.back(-1)
  310. }
  311. })
  312. } else {
  313. return false
  314. }
  315. })
  316. }
  317. },
  318. created() {
  319. var year = new Date().getFullYear()
  320. var month = new Date().getMonth() + 1
  321. var day = new Date().getDate()
  322. if (parseInt(month) < 10) {
  323. month = '0' + month
  324. }
  325. if (parseInt(day) < 10) {
  326. day = '0' + day
  327. }
  328. const endTime = year + '-' + month + '-' + day
  329. this.return_time = endTime
  330. const tempObj = {}
  331. tempObj['good_type_id'] = 0
  332. tempObj['good_id'] = 0
  333. tempObj['return_count'] = ''
  334. this.recordInfo.recordData.push(tempObj)
  335. this.GetConfigInfo()
  336. this.propForm.goodUnit = this.$store.getters.good_unit
  337. }
  338. }
  339. </script>
  340. <style rel="stylesheet/css" lang="scss" scoped>
  341. .information {
  342. border: 1px #dcdfe6 solid;
  343. padding: 30px 20px 30px 20px;
  344. .border {
  345. border-bottom: 1px #dcdfe6 solid;
  346. margin: 0px 0 20px 0;
  347. }
  348. }
  349. .edit_separater {
  350. border-top: 1px solid rgb(233, 233, 233);
  351. margin-top: 15px;
  352. margin-bottom: 15px;
  353. }
  354. </style>
  355. <style>
  356. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  357. font-size: 12px;
  358. }
  359. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  360. background: #6fb5fa;
  361. }
  362. </style>