ns-exwarehouse.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="ns-to">
  3. <view class="title">
  4. 产品{{ keys_type }}
  5. <text class="iconfont iconguanbi1" @click="close"></text>
  6. </view>
  7. <view class="ns-body" v-if="sku_list.length">
  8. <view class="item-type1">
  9. <view class="item-left">产品名称:</view>
  10. <view>{{ sku_list[0].goods_name }}</view>
  11. </view>
  12. <view class="item-type1 item-type2">
  13. <view class="item-left">{{ keys_type }}类型:</view>
  14. <view class="type2-right type3-right" v-if="documentTypeList.length > 0">
  15. <picker @change="bindtypeChange" :value="type_index" :range="documentTypeList" :range-key="'name'">
  16. <view class="uni-input">
  17. {{ documentTypeList[type_index].name }}
  18. <text class="iconfont iconxiala"></text>
  19. </view>
  20. </picker>
  21. </view>
  22. </view>
  23. <view class="item-type1 item-type2" v-if="sku_list.length > 1">
  24. <view class="item-left">规格选择:</view>
  25. <view class="type2-right type3-right">
  26. <picker @change="bindskuChange" :value="sku_index" :range="sku_list" :range-key="'spec_name'">
  27. <view class="uni-input">
  28. {{ sku_list[sku_index].spec_name }}
  29. <text class="iconfont iconxiala"></text>
  30. </view>
  31. </picker>
  32. </view>
  33. </view>
  34. <view class="item-type1">
  35. <view class="item-left">当前库存:</view>
  36. <view>{{ sku_list[sku_index].stock }}</view>
  37. </view>
  38. <view class="item-type1 item-type4">
  39. <view class="item-left">{{ keys_type }}时间:</view>
  40. <view class="type2-right type3-right"><uni-datetime-picker type="datetime" v-model="dateTime" @change="changeTime" /></view>
  41. </view>
  42. <view class="item-type1">
  43. <view class="item-left">{{ keys_type }}数量:</view>
  44. <view class="item-right"><input type="number" v-model="num" :placeholder="'请输入' + keys_type + '数量'" /></view>
  45. </view>
  46. <view class="item-type1" v-if="keys == 'input'">
  47. <view class="item-left">{{ keys_type }}单价:</view>
  48. <view class="item-right"><input type="digit" v-model="price" :placeholder="'请输入' + keys_type + '单价'" /></view>
  49. </view>
  50. <view class="item-type1" v-if="keys == 'input'">
  51. <view class="item-left">总金额:</view>
  52. <view>{{ parseFloat(parseFloat(num) * parseFloat(price).toFixed(2)).toFixed(2) }}</view>
  53. </view>
  54. <view class="item-type3">
  55. <view class="item-left">备注:</view>
  56. <view class="item-right"><textarea class="textarea" maxlength="100" placeholder="请输入备注,不能超过100个字符" v-model="remark"></textarea></view>
  57. </view>
  58. <view class="bottom-btn">
  59. <button type="primary" class="primary-btn btn" @click="operation">保存</button>
  60. <button type="primary" class="default-btn btn save" @click="close">取消</button>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import unidatetimepicker from '@/components/uni-datetime-picker/uni-datetime-picker.vue';
  67. export default {
  68. components: {
  69. unidatetimepicker
  70. },
  71. props: {
  72. documentTypeList: {
  73. type: Array,
  74. default: () => {
  75. return [];
  76. }
  77. },
  78. sku_list: {
  79. type: Array,
  80. default: () => {
  81. return [];
  82. }
  83. },
  84. //弹窗 -- 标题(出库 || 入库)
  85. keys: {
  86. type: String,
  87. default: () => {
  88. return '';
  89. }
  90. }
  91. },
  92. data() {
  93. return {
  94. //出入库选择
  95. type_index: 0,
  96. //规格选择
  97. sku_index: 0,
  98. //时间数据
  99. dateTime: '',
  100. // 入库数量
  101. num: 0,
  102. // 入库单价
  103. price: 0,
  104. //发表留言
  105. remark: '',
  106. // 出入库时间
  107. time: '',
  108. //出路库类型
  109. keys_type: '入库',
  110. // 防重复操作
  111. set_judge: false
  112. };
  113. },
  114. mounted() {
  115. if (this.keys == 'output') {
  116. this.keys_type = '出库';
  117. } else {
  118. this.keys_type = '入库';
  119. }
  120. let myDate = new Date();
  121. let Y = myDate.getFullYear();
  122. let M = myDate.getMonth() + 1;
  123. let D = myDate.getDate();
  124. let H = myDate.getHours();
  125. let Min = myDate.getMinutes();
  126. this.$nextTick(() => {
  127. this.dateTime = Y + '-' + M + '-' + D + ' ' + H + ':' + Min + ':00';
  128. });
  129. },
  130. methods: {
  131. // 出入库类型选择
  132. bindtypeChange(e) {
  133. this.type_index = e.detail.value;
  134. },
  135. // 规格选择
  136. bindskuChange(e) {
  137. this.sku_index = e.detail.value;
  138. },
  139. // 弹窗关闭
  140. close() {
  141. this.$emit('close', 'put');
  142. },
  143. // 设置时间
  144. changeTime(e) {
  145. this.time = e;
  146. },
  147. // 请求出库入库操作
  148. operation() {
  149. if (this.set_judge) return;
  150. this.set_judge = true;
  151. let data = {
  152. sku_id: this.sku_list[this.sku_index].sku_id,
  153. remark: this.remark,
  154. goods_num: this.num,
  155. time: this.time,
  156. key: this.documentTypeList[this.type_index].key
  157. };
  158. if (this.num < 0 || this.num == 0) {
  159. this.$util.showToast({
  160. title: this.keys_type + '数量必须为大于0的整数'
  161. });
  162. this.set_judge = false;
  163. return;
  164. }
  165. if (this.keys == 'input') {
  166. data.goods_price = this.price;
  167. } else {
  168. if (parseFloat(this.num) > parseFloat(this.sku_list[this.sku_index].stock)) {
  169. this.$util.showToast({
  170. title: '出库数量,请勿大于当前库存'
  171. });
  172. this.set_judge = false;
  173. return;
  174. }
  175. }
  176. this.$emit('operation', data, res => {
  177. this.set_judge = res.judge;
  178. });
  179. }
  180. },
  181. watch: {
  182. num() {
  183. if (!this.num) {
  184. this.num = 0;
  185. }
  186. this.$forceUpdate();
  187. },
  188. price() {
  189. if (!this.price) {
  190. this.price = 0;
  191. }
  192. this.$forceUpdate();
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss" scoped>
  198. .ns-to {
  199. width: 100%;
  200. height: 100%;
  201. background: #ffffff;
  202. border-radius: 0.04rem;
  203. view {
  204. color: #303133 !important;
  205. }
  206. .title {
  207. width: 100%;
  208. height: 0.5rem;
  209. border-bottom: 0.01rem solid #e6e6e6;
  210. font-size: 0.16rem;
  211. line-height: 0.5rem;
  212. text-align: center;
  213. position: relative;
  214. font-weight: bold;
  215. .iconguanbi1 {
  216. font-size: 0.2rem;
  217. position: absolute;
  218. top: 50%;
  219. right: 0.15rem;
  220. transform: translateY(-50%);
  221. font-weight: 500;
  222. }
  223. }
  224. .ns-body {
  225. width: 100%;
  226. height: calc(100% - 0.5rem);
  227. padding: 0.15rem 0.15rem 0.2rem 0.15rem;
  228. box-sizing: border-box;
  229. .item-type1 {
  230. display: flex;
  231. align-items: center;
  232. margin-top: 0.2rem;
  233. view {
  234. font-size: 0.16rem;
  235. }
  236. .item-left {
  237. width: 1.6rem;
  238. text-align: right;
  239. padding-right: 0.15rem;
  240. }
  241. .item-right {
  242. width: 2.1rem;
  243. height: 0.3rem;
  244. border: 0.01rem solid #e6e6e6;
  245. display: flex;
  246. align-items: center;
  247. padding-left: 0.1rem;
  248. input {
  249. font-size: 0.14rem;
  250. }
  251. }
  252. }
  253. .item-type2 {
  254. .type2-right {
  255. // text-align: right;
  256. }
  257. .type3-right {
  258. width: 2.2rem;
  259. height: 0.32rem;
  260. line-height: 0.32rem;
  261. border: 0.01rem solid #e6e6e6;
  262. padding-left: 0.1rem;
  263. .uni-input {
  264. display: flex;
  265. align-items: center;
  266. justify-content: space-between;
  267. }
  268. .iconxiala {
  269. font-size: 0.2rem;
  270. margin-right: 0.15rem;
  271. }
  272. }
  273. }
  274. .item-type3 {
  275. margin-top: 0.2rem;
  276. view {
  277. font-size: 0.16rem;
  278. float: left;
  279. }
  280. .item-left {
  281. width: 1.6rem;
  282. text-align: right;
  283. padding-right: 0.15rem;
  284. }
  285. .item-right {
  286. width: 2.1rem;
  287. height: 1rem;
  288. padding: 0.1rem;
  289. border: 0.01rem solid #e6e6e6;
  290. .textarea {
  291. width: 100%;
  292. height: 100%;
  293. font-size: 0.14rem;
  294. }
  295. }
  296. }
  297. .item-type3:after {
  298. content: '';
  299. height: 0;
  300. display: block;
  301. clear: both;
  302. overflow: hidden;
  303. }
  304. .item-type4 {
  305. .type2-right {
  306. text-align: left;
  307. width: 2.2rem;
  308. height: 0.3rem;
  309. /deep/ .uni-date {
  310. height: 100% !important;
  311. }
  312. }
  313. }
  314. .bottom-btn {
  315. width: 100%;
  316. padding-top: 0.4rem;
  317. .btn {
  318. float: right;
  319. }
  320. .save {
  321. margin-right: 0.1rem;
  322. }
  323. }
  324. .bottom-btn:after {
  325. content: '';
  326. height: 0;
  327. display: block;
  328. clear: both;
  329. overflow: hidden;
  330. }
  331. }
  332. }
  333. /deep/ .uni-date-editor {
  334. height: 100% !important;
  335. }
  336. /deep/ .uni-date-editor--x {
  337. height: 100% !important;
  338. }
  339. /deep/ .uni-date-single {
  340. height: 100% !important;
  341. }
  342. /deep/ .uni-date-editor--x .uni-date__icon-clear {
  343. top: -0.03rem;
  344. }
  345. </style>