血透系统PC前端

cancelStockOrderAdd.vue 13KB

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