stockOutOrderEdit.vue 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb v-if="this.$route.query.type == 1" :crumbs='crumbs'></bread-crumb>
  5. <bread-crumb v-if="this.$route.query.type == 2" :crumbs='crumbs2'></bread-crumb>
  6. <div style="float:right;">
  7. <el-button size="small" @click="back()" class="filter-item">取 消</el-button>
  8. <el-button size="small" type="primary" @click="submit()" class="filter-item">保 存</el-button>
  9. </div>
  10. </div>
  11. <div class="app-container">
  12. <!--<stock-in-dialog-->
  13. <!--ref="dialog"-->
  14. <!--:propForm="propForm"-->
  15. <!--:visibility="isVisibility"-->
  16. <!--v-on:dialog-comfirm="comfirm"-->
  17. <!--v-on:dialog-cancle="cancle"-->
  18. <!--&gt;</stock-in-dialog>-->
  19. <stock-in-dialog
  20. ref="dialog"
  21. :propForm="propForm"
  22. :visibility="isVisibility"
  23. v-on:dialog-comfirm="comfirm"
  24. v-on:dialog-cancle="cancle"
  25. >
  26. </stock-in-dialog>
  27. <div class="cell clearfix">
  28. <label class="title"><span class="name">出库时间</span> : </label>
  29. <el-date-picker size="small" v-model="warehouse_out_time" prefix-icon="el-icon-date" :editable="false"
  30. style="width: 196px;"
  31. type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
  32. value-format="yyyy-MM-dd"></el-date-picker>
  33. </div>
  34. <div class="cell clearfix">
  35. <label class="title"><span class="name">经销商</span> : </label>
  36. <el-select size="small" v-model="form.dealer" clearable placeholder="请选择经销商" @change="changeDealer">
  37. <el-option
  38. v-for="(option, index) in dealer"
  39. :key="index"
  40. :label="option.dealer_name"
  41. :value="option.id">
  42. </el-option>
  43. </el-select>
  44. </div>
  45. <div class="cell clearfix">
  46. <label class="title"><span class="name">厂商</span> : </label>
  47. <el-select size="small" v-model="form.manufacturer" clearable placeholder="请选择厂商" @change="changeManufacturer">
  48. <el-option
  49. v-for="(option, index) in manufacturer"
  50. :key="index"
  51. :label="option.manufacturer_name"
  52. :value="option.id">
  53. </el-option>
  54. </el-select>
  55. </div>
  56. <el-form :rules="tableRules" :model="recordInfo" ref="tableForm">
  57. <el-table :data="recordInfo.recordData" :class="signAndWeighBoxPatients" style="width: 100%" border
  58. max-height="450" :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  59. >
  60. <el-table-column min-width="35" align="center">
  61. <template slot="header" slot-scope="scope">
  62. <span>耗材类型<span style="color: red">*</span></span>
  63. </template>
  64. <template slot-scope="scope">
  65. <el-form-item style="padding-top: 15px">
  66. <el-input placeholder="请输入商品类型" v-model="scope.row.good_type_id"
  67. :value="typeName(scope.row.good_type_id)"
  68. @focus="showDialog(scope.$index, scope.row)"></el-input>
  69. </el-form-item>
  70. </template>
  71. </el-table-column>
  72. <el-table-column min-width="35" align="center">
  73. <template slot="header" slot-scope="scope">
  74. <span>规格名称<span style="color: red">*</span></span>
  75. </template>
  76. <template slot-scope="scope">
  77. <el-form-item style="padding-top: 15px">
  78. <el-input placeholder="请输入规格名称" v-model="scope.row.good_id"
  79. :value="specificationName(scope.row.good_id)"
  80. @focus="showDialog(scope.$index, scope.row)"></el-input>
  81. </el-form-item>
  82. </template>
  83. </el-table-column>
  84. <el-table-column min-width="23" align="center">
  85. <template slot="header" slot-scope="scope">
  86. <span>单价<span style="color: red">*</span></span>
  87. </template>
  88. <template slot-scope="scope">
  89. <!--<el-input type="number" v-model="scope.row.price" @blur="handleBlur(scope.$index, scope.row)"></el-input>-->
  90. <el-form-item :prop="'recordData.' + scope.$index + '.price'" :rules='tableRules.price'
  91. style="padding-top: 17px">
  92. <el-input type="number" v-model="scope.row.price"></el-input>
  93. </el-form-item>
  94. </template>
  95. </el-table-column>
  96. <el-table-column min-width="23" align="center">
  97. <template slot="header" slot-scope="scope">
  98. <span>出库数量<span style="color: red">*</span></span>
  99. </template>
  100. <template slot-scope="scope">
  101. <el-form-item :prop="'recordData.' + scope.$index + '.count'" :rules='tableRules.count'
  102. style="padding-top: 17px">
  103. <el-input type="number" v-model="scope.row.count"></el-input>
  104. </el-form-item>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="总价" min-width="20" align="center">
  108. <template slot-scope="scope">
  109. {{calculate(scope.row.price*scope.row.count)}}
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="备注" min-width="20" align="center">
  113. <template slot-scope="scope">
  114. <el-input v-model="scope.row.remark"></el-input>
  115. </template>
  116. </el-table-column>
  117. <el-table-column label="操作" align="center" min-width="20">
  118. <template slot-scope="scope">
  119. <el-tooltip class="item" effect="dark" content="新增" placement="top">
  120. <el-button
  121. size="mini"
  122. type="primary"
  123. icon="el-icon-circle-plus-outline"
  124. @click="handleEdit(scope.$index, scope.row)">
  125. </el-button>
  126. </el-tooltip>
  127. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  128. <el-button
  129. size="mini"
  130. type="danger"
  131. icon="el-icon-delete"
  132. @click="handleDelete(scope.$index, scope.row)">
  133. </el-button>
  134. </el-tooltip>
  135. </template>
  136. </el-table-column>
  137. </el-table>
  138. </el-form>
  139. </div>
  140. </div>
  141. </template>
  142. <script>
  143. import { uParseTime } from '@/utils/tools'
  144. import { deleteWarehouseOutInfo, editWarehouseoutInfo, getSalesReturnConfig, getWarehouseOutInfo,GetAllConfig,GetAllGoodInfoByID } from '@/api/stock'
  145. import BreadCrumb from '../components/bread-crumb'
  146. import StockInDialog from './Dialog/stockInDialog'
  147. export default {
  148. components: { StockInDialog, BreadCrumb},
  149. name: 'salesReturnEdit',
  150. data() {
  151. return {
  152. crumbs: [
  153. { path: false, name: '库存管理' },
  154. { path: false, name: '耗材出库单' },
  155. { path: false, name: '编辑出库单' }
  156. ],
  157. crumbs2: [
  158. { path: false, name: '库存管理' },
  159. { path: false, name: '其他出库单' },
  160. { path: false, name: '编辑出库单' }
  161. ],
  162. signAndWeighBoxPatients: 'sign-and-weigh-box-patients',
  163. adminUserOptions: null,
  164. currentIndex: 0,
  165. warehouse_out_time: '',
  166. recordInfo: {
  167. recordData: [],
  168. stock_in_code: '',
  169. current_index: ''
  170. },
  171. tableRules: {
  172. count: [
  173. { required: true, message: '数量不能为空', trigge: 'blur' }
  174. ],
  175. price: [
  176. { required: true, message: '单价不能为空', trigger: 'blur' }
  177. ]
  178. },
  179. ruleForm: {
  180. manufacturer: [
  181. { required: true, message: '请选择厂商', trigger: 'change' }
  182. ]
  183. },
  184. // prop
  185. isVisibility: false,
  186. propForm: {
  187. goods:[],
  188. goodType: [],
  189. goodInfo: [],
  190. goodUnit: [],
  191. title: '入库',
  192. manufacturer: 0,
  193. dealer: 0
  194. },
  195. form: {
  196. manufacturer: 0,
  197. dealer: 0
  198. },
  199. warehouseInfoList: [],
  200. warehouseOut: {},
  201. manufacturer: [],
  202. dealer: [],
  203. goodType: [],
  204. goodInfo:[],
  205. }
  206. },
  207. methods: {
  208. comfirm: function(val) {
  209. this.$refs.dialog.hide();
  210. this.propForm.goodType = [];
  211. this.propForm.goods = [];
  212. if (val.selectedGoodInfo.length > 0) {
  213. for (let i = val.selectedGoodInfo.length - 1; ; i--) {
  214. if (i == 0) {
  215. this.recordInfo.recordData[this.currentIndex].good_type_id =
  216. val.selectedGoodInfo[i].good_type_id;
  217. this.recordInfo.recordData[this.currentIndex].good_id =
  218. val.selectedGoodInfo[i].id;
  219. this.recordInfo.recordData[
  220. this.currentIndex
  221. ].price = val.selectedGoodInfo[i].buy_price.toString();
  222. } else {
  223. const tempForm = {};
  224. tempForm["id"] = 0;
  225. tempForm["good_type_id"] = val.selectedGoodInfo[i].good_type_id;
  226. tempForm["good_id"] = val.selectedGoodInfo[i].id;
  227. tempForm["count"] = "";
  228. tempForm["price"] = val.selectedGoodInfo[i].buy_price.toString();
  229. tempForm["remark"] = "";
  230. this.recordInfo.recordData.splice(
  231. this.currentIndex + 1,
  232. 0,
  233. tempForm
  234. );
  235. }
  236. }
  237. }
  238. this.currentIndex = -1;
  239. },
  240. cancle: function() {
  241. this.$refs.dialog.hide()
  242. this.propForm.goods = [];
  243. this.propForm.goodType = [];
  244. }, GetConfigInfo: function() {
  245. const loading = this.$loading({
  246. lock: true,
  247. text: "Loading",
  248. spinner: "el-icon-loading",
  249. background: "rgba(0, 0, 0, 0.7)"
  250. });
  251. GetAllConfig().then(response => {
  252. if (response.data.state == 0) {
  253. this.$message.error(response.data.msg);
  254. return false;
  255. } else {
  256. this.manufacturer = response.data.data.manufacturer;
  257. this.dealer = response.data.data.dealer;
  258. this.goodType = response.data.data.goodType;
  259. this.goodInfo = response.data.data.goodInfo;
  260. this.manufacturer.splice(0, 0, { id: 0, manufacturer_name: "全部" });
  261. this.dealer.splice(0, 0, { id: 0, dealer_name: "全部" });
  262. }
  263. loading.close();
  264. });
  265. }, typeName: function(good_type_id) {
  266. let name = "";
  267. for (let i = 0; i < this.goodType.length; i++) {
  268. if (this.goodType[i].id == good_type_id) {
  269. name = this.goodType[i].type_name;
  270. }
  271. }
  272. return name;
  273. }, specificationName: function(good_info_id) {
  274. let name = "";
  275. for (let i = 0; i < this.goodInfo.length; i++) {
  276. if (this.goodInfo[i].id == good_info_id) {
  277. name = this.goodInfo[i].specification_name;
  278. }
  279. }
  280. return name;
  281. },
  282. handleEdit: function(index, row) {
  283. const tempObj = {}
  284. tempObj['id'] = 0
  285. tempObj['good_type_id'] = 0
  286. tempObj['good_id'] = 0
  287. tempObj['count'] = ''
  288. tempObj['price'] = ''
  289. tempObj['remark'] = ''
  290. this.recordInfo.recordData.push(tempObj)
  291. }, handleDelete: function(index, row) {
  292. if (row.id == 0) {
  293. this.recordInfo.recordData.splice(index, 1)
  294. } else {
  295. const params = {
  296. id: row.id
  297. }
  298. this.$confirm('确认删除该出库耗材信息记录?', '删除出库耗材信息记录', {
  299. confirmButtonText: '确定',
  300. cancelButtonText: '取消',
  301. type: 'warning'
  302. }).then(() => {
  303. deleteWarehouseOutInfo(params).then(response => {
  304. if (response.data.state == 0) {
  305. this.$message.error(response.data.msg)
  306. return false
  307. } else {
  308. this.$message.success('删除成功')
  309. this.recordInfo.recordData.splice(index, 1)
  310. }
  311. })
  312. }).catch(() => {
  313. })
  314. }
  315. }, getTime(val, temp) {
  316. if (val != 0) {
  317. return uParseTime(val, temp)
  318. } else {
  319. return ''
  320. }
  321. },
  322. showDialog(index, row) {
  323. this.currentIndex = index;
  324. const loading = this.$loading({
  325. lock: true,
  326. text: "Loading",
  327. spinner: "el-icon-loading",
  328. background: "rgba(0, 0, 0, 0.7)"
  329. });
  330. const params = {
  331. manufacturer_id: this.form.manufacturer,
  332. dealer_id: this.form.dealer
  333. };
  334. this.propForm.goods = []
  335. GetAllGoodInfoByID(params).then(response => {
  336. if (response.data.state == 0) {
  337. this.$message.error(response.data.msg);
  338. return false;
  339. } else {
  340. if (response.data.data.goodInfo.length <= 0) {
  341. this.$message.error("该厂商或经销商没有物品信息");
  342. return;
  343. }
  344. this.$refs.dialog.show();
  345. for (let i = 0; i < response.data.data.goodInfo.length; i++) {
  346. this.propForm.goodType.push(
  347. response.data.data.goodInfo[i].type
  348. );
  349. }
  350. const obj = {};
  351. this.propForm.goodType = this.propForm.goodType.reduce(
  352. (cur, next) => {
  353. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  354. return cur;
  355. },
  356. []
  357. ); // 设置cur默认类型为数组,并且初始值为空的数组
  358. }
  359. for (let i = 0; i < this.propForm.goodType.length; i++) {
  360. let goodInfo = [];
  361. let goodObj = {};
  362. for (let a = 0; a < response.data.data.goodInfo.length; a++) {
  363. var respObj = response.data.data.goodInfo[a];
  364. respObj["isSelected"] = false;
  365. if (respObj.type.id == this.propForm.goodType[i].id) {
  366. goodInfo.push(respObj);
  367. }
  368. }
  369. const obj = {};
  370. goodInfo = goodInfo.reduce((cur, next) => {
  371. obj[next.id] ? "" : (obj[next.id] = true && cur.push(next));
  372. return cur;
  373. }, []); // 设置cur默认类型为数组,并且初始值为空的数组
  374. this.$set(goodObj, this.propForm.goodType[i].id, goodInfo);
  375. this.propForm.goods.push(goodObj);
  376. }
  377. loading.close();
  378. });
  379. },
  380. back() {
  381. this.$router.go(-1)
  382. },
  383. submit() {
  384. this.$refs['tableForm'].validate((valid) => {
  385. if (valid) {
  386. const array = this.recordInfo.recordData
  387. for (let i = 0; i < array.length; i++) {
  388. if (array[i].good_type_id == 0) {
  389. this.$message.error('商品类型不能为空')
  390. return
  391. }
  392. if (array[i].good_id == 0) {
  393. this.$message.error('规格名称不能为空')
  394. return
  395. }
  396. }
  397. const params = {
  398. 'stockOut': this.recordInfo.recordData
  399. }
  400. editWarehouseoutInfo(params, this.warehouse_out_time, this.$route.query.id, this.$route.query.type, this.form.manufacturer, this.form.dealer).then(response => {
  401. if (response.data.state == 0) {
  402. this.$message.error(response.data.msg)
  403. return false
  404. } else {
  405. this.$message.success('保存成功')
  406. this.$router.back(-1)
  407. }
  408. })
  409. } else {
  410. return false
  411. }
  412. })
  413. }, GetOrderDetail: function(order_id) {
  414. const params = {
  415. 'id': order_id
  416. }
  417. getWarehouseOutInfo(params).then(response => {
  418. if (response.data.state == 0) {
  419. this.$message.error(response.data.msg)
  420. return false
  421. } else {
  422. for (let i = 0; i < response.data.data.list.length; i++) {
  423. response.data.data.list[i].price = response.data.data.list[i].price.toString()
  424. response.data.data.list[i].count = response.data.data.list[i].count.toString()
  425. this.recordInfo.recordData.push(response.data.data.list[i])
  426. }
  427. this.warehouseOut = response.data.data.info
  428. this.warehouse_out_time = this.getTime(this.warehouseOut.warehouse_out_time, '{y}-{m}-{d}')
  429. this.form.manufacturer = this.warehouseOut.manufacturer
  430. this.form.dealer = this.warehouseOut.dealer
  431. }
  432. if (this.recordInfo.recordData.length == 0) {
  433. const tempObj = {}
  434. tempObj['id'] = 0
  435. tempObj['good_type_id'] = 0
  436. tempObj['good_id'] = 0
  437. tempObj['count'] = ''
  438. tempObj['price'] = ''
  439. tempObj['remark'] = ''
  440. this.recordInfo.recordData.push(tempObj)
  441. }
  442. })
  443. }, calculate: function(val) {
  444. if (val == 0) {
  445. return ''
  446. }
  447. return Math.round(parseFloat(val) * 100) / 100
  448. }, changeManufacturer(val) {
  449. this.propForm.manufacturer = val
  450. }, changeDealer(val) {
  451. this.propForm.dealer = val
  452. }
  453. },
  454. created() {
  455. this.GetConfigInfo()
  456. this.propForm.goodUnit = this.$store.getters.good_unit
  457. const order_id = this.$route.query.id
  458. this.GetOrderDetail(order_id)
  459. }
  460. }
  461. </script>
  462. <style rel="stylesheet/css" lang="scss" scoped>
  463. .information {
  464. border: 1px #dcdfe6 solid;
  465. padding: 30px 20px 30px 20px;
  466. .border {
  467. border-bottom: 1px #dcdfe6 solid;
  468. margin: 0px 0 20px 0;
  469. }
  470. }
  471. .edit_separater {
  472. border-top: 1px solid rgb(233, 233, 233);
  473. margin-top: 15px;
  474. margin-bottom: 15px;
  475. }
  476. </style>
  477. <style>
  478. .sign-and-weigh-box .sign-and-weigh-box-patients .cell {
  479. font-size: 12px;
  480. }
  481. .sign-and-weigh-box .sign-and-weigh-box-patients .current-row > td {
  482. background: #6fb5fa;
  483. }
  484. </style>