血透系统PC前端

cancelStockOrderEdit.vue 12KB

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