Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

cancelStockOrderAdd.vue 16KB

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