order.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="price" :class="showCalendar?'popupShow':''">
  3. <view class="picker-btn">
  4. <view class="btn">
  5. <button type="primary" @click="batchAdd">
  6. {{$t('spare.chooseSpare')}}
  7. </button>
  8. </view>
  9. <view class="btn">
  10. <button type="primary" @click="sureChangePrice">
  11. {{$t('settings.confirmText')}}
  12. </button>
  13. </view>
  14. </view>
  15. <template v-if="details.length">
  16. <template v-if="encode =='applyOrder'">
  17. <view class="order-card" v-for="(item, index) in details" :key="index">
  18. <view class="order-info">
  19. <p class="info-line">
  20. <text class="label">{{$t('spare.spareName')}}:</text>
  21. <text class="info">
  22. {{`${item.code}_${item.name}_${item.spec}_${getLabel(item.unit,unitList)}`}}
  23. </text>
  24. </p>
  25. <p class="info-line">
  26. <text class="label">{{$t('spare.orderNum')}}</text>
  27. <u-input class="info"
  28. suffixIcon="edit-pen" border="none"
  29. type="number" v-model="item.number"
  30. :placeholder="$t('base.common.placeholderI')+$t('spare.orderNum')"/>
  31. </p>
  32. <p class="info-line">
  33. <text class="label">{{$t('spare.noTaxPrice')}}</text>
  34. <u-input class="info"
  35. suffixIcon="edit-pen" border="none"
  36. type="number" v-model="item.price"
  37. :placeholder="$t('base.common.placeholderI')+$t('spare.noTaxPrice')"/>
  38. </p>
  39. <p class="info-line">
  40. <text class="label">{{$t('spare.taxPrice')}}:</text>
  41. <u-input class="info"
  42. suffixIcon="edit-pen" border="none"
  43. type="number" v-model="item.taxPrice"
  44. :placeholder="$t('base.common.placeholderI')+$t('spare.taxPrice')"/>
  45. </p>
  46. <p class="info-line">
  47. <text class="label">{{$t('spare.tax')}}:</text>
  48. <u-input class="info"
  49. suffixIcon="edit-pen" border="none"
  50. type="number" v-model="item.cess"
  51. :placeholder="$t('base.common.placeholderI')+$t('spare.tax')"/>
  52. </p>
  53. <p class="info-line">
  54. <text class="label">{{$t('spare.transportPrice')}}:</text>
  55. <u-input class="info"
  56. suffixIcon="edit-pen" border="none"
  57. type="number" v-model="item.freightPrice"
  58. :placeholder="$t('base.common.placeholderI')+$t('spare.transportPrice')"/>
  59. </p>
  60. <p class="info-line">
  61. <text class="label">{{$t('spare.arriveDate')}}:</text>
  62. <text class="info" @click="setArrivalDate(index)">
  63. <template v-if="item.arrivalDate">
  64. {{item.arrivalDate}}
  65. </template>
  66. <template v-else>
  67. {{$t('spare.chooseDate')}}
  68. </template></text>
  69. </p>
  70. <p class="info-line">
  71. <text class="label">{{$t('approval.remark')}}:</text>
  72. <u-input suffixIcon="edit-pen" border="none"
  73. v-model="item.remark"
  74. :placeholder="$t('base.common.placeholderI')+$t('spare.remark')"/>
  75. </p>
  76. </view>
  77. </view>
  78. </template>
  79. <template v-if="encode =='applyTake'">
  80. <view class="order-card" v-for="(item, index) in details" :key="index">
  81. <view class="order-info">
  82. <p class="info-line">
  83. <text class="label">{{$t('spare.spareName')}}:</text>
  84. <text class="info">
  85. {{`${item.code}_${item.name}_${item.spec}_${getLabel(item.unit,unitList)}`}}
  86. </text>
  87. </p>
  88. <p class="info-line">
  89. <text class="label">{{$t('spare.applyNum')}}</text>
  90. <u-input class="info"
  91. suffixIcon="edit-pen" border="none"
  92. type="number" v-model="item.number"
  93. :placeholder="$t('base.common.placeholderI')+$t('spare.applyNum')"/>
  94. </p>
  95. <p class="info-line">
  96. <text class="label">{{$t('spare.price')}}</text>
  97. <u-input class="info"
  98. suffixIcon="edit-pen" border="none"
  99. type="number" v-model="item.price"
  100. :placeholder="$t('base.common.placeholderI')+$t('spare.price')"/>
  101. </p>
  102. <p class="info-line">
  103. <text class="label">{{$t('approval.remark')}}:</text>
  104. <u-input class="info" suffixIcon="edit-pen" border="none"
  105. v-model="item.remark"
  106. :placeholder="$t('base.common.placeholderI')+$t('spare.remark')"/>
  107. </p>
  108. </view>
  109. </view>
  110. </template>
  111. </template>
  112. <template v-else>
  113. <u-empty mode="list" text='请先选择申请备件' icon="https://cdn.uviewui.com/uview/empty/list.png">
  114. </u-empty>
  115. </template>
  116. <!-- 到货日期 -->
  117. <u-calendar
  118. color="#4680F9"
  119. round='25'
  120. :show="showCalendar"
  121. @confirm="onDateConfirm"
  122. @close="showCalendar=false">
  123. </u-calendar>
  124. </view>
  125. </template>
  126. <script>
  127. import { getLabel } from '../../utils/util'
  128. import {request} from '../../utils/request'
  129. import dayjs from 'dayjs'
  130. export default {
  131. data(){
  132. return {
  133. getLabel,
  134. showCalendar:false,
  135. details:[],
  136. currentIndex:'',
  137. keyword:'',
  138. spareKeyword:'',
  139. detailList:[], //选择的备件
  140. currentTreeId:'',
  141. unitList:[],
  142. encode:'',
  143. }
  144. },
  145. onLoad(options) {
  146. this.encode = options.encode
  147. if(this.encode == 'applyTake'){
  148. uni.setNavigationBarTitle({
  149. title: '领用申请'
  150. });
  151. }else if(this.encode == 'applyOrder'){
  152. uni.setNavigationBarTitle({
  153. title: '采购订单'
  154. });
  155. }
  156. this.getSpareTree()
  157. },
  158. onReady() {
  159. },
  160. methods:{
  161. //批量添加
  162. batchAdd(){
  163. uni.navigateTo({ url: `/subpages/spare/batchAdd`})
  164. },
  165. //确认调价
  166. sureChangePrice(){
  167. let pages = getCurrentPages();
  168. let prevPage = pages[pages.length - 2]; //上一个页面
  169. if(this.encode == 'applyTake'){
  170. prevPage.$vm.form.details = this.details;
  171. }else if(this.encode == 'applyOrder'){
  172. prevPage.$vm.form.detailList = this.details;
  173. }
  174. uni.navigateBack();
  175. },
  176. //备件大类
  177. getSpareTree(){
  178. //获取单位
  179. request({
  180. url:'/admin/dict/type/spare_unit',
  181. method:'get',
  182. })
  183. .then(res=>{
  184. if(res.data.code == 0){
  185. this.unitList = res.data.data
  186. }
  187. })
  188. },
  189. //确认选择备件
  190. spareConfirm(){
  191. this.detailList.forEach(item=>{
  192. let obj = JSON.parse(item)
  193. let isHave = false
  194. this.details.forEach(i=>{
  195. if(obj.id == i.id){
  196. isHave = true
  197. }
  198. })
  199. if(!isHave){
  200. if(this.encode == 'applyOrder'){
  201. obj.number=undefined
  202. obj.price=undefined
  203. obj.taxPrice=undefined
  204. obj.freightPrice=undefined
  205. obj.arrivalDate = undefined
  206. obj.remark=undefined
  207. }else if(this.encode == 'applyTake'){
  208. obj.number=undefined
  209. obj.remark=undefined
  210. obj.price=undefined
  211. obj.materialId = obj.id
  212. }
  213. this.details.push(obj)
  214. }
  215. })
  216. this.details.forEach((item,index)=>{
  217. let isHave = false
  218. this.detailList.forEach(i=>{
  219. let obj = JSON.parse(i)
  220. if(obj.id == item.id){
  221. isHave = true
  222. }
  223. })
  224. if(!isHave){
  225. this.details.splice(index,1)
  226. }
  227. })
  228. },
  229. //重新计算单价和含税单价
  230. priceChange(row, index) {
  231. row.taxPrice = row.price * (1 + (row.cess / 100));
  232. },
  233. //重新计算单价和含税单价
  234. taxPriceChange(row, index) {
  235. row.price = row.taxPrice / (1 + (row.cess / 100));
  236. },
  237. //打开日期选择
  238. setArrivalDate(index){
  239. this.currentIndex = index
  240. this.showCalendar = true
  241. },
  242. //选择调价日期
  243. onDateConfirm(date){
  244. this.details[this.currentIndex].arrivalDate = dayjs(date).format('YYYY-MM-DD')
  245. console.log(this.details);
  246. this.showCalendar = false;
  247. },
  248. }
  249. }
  250. </script>
  251. <style lang="scss" scoped>
  252. @import '../../common/css/apply.scss';
  253. @import '../../common/css/approval.scss';
  254. /* #ifndef APP-NVUE */
  255. view {
  256. display: flex;
  257. box-sizing: border-box;
  258. flex-direction: column;
  259. }
  260. page {
  261. background-color: #f8f8f8;
  262. }
  263. /* #endif*/
  264. .price{
  265. /* #ifndef APP-NVUE */
  266. display: flex;
  267. width: 750rpx;
  268. min-height: 100vh;
  269. /* #endif */
  270. flex-direction: column;
  271. flex: 1;
  272. background-color: #f8f8f8;
  273. padding-bottom: 160rpx;
  274. .picker-btn{
  275. padding: 32rpx;
  276. position: fixed;
  277. bottom: 0;
  278. width: 100%;
  279. flex-direction: row;
  280. justify-content: space-between;
  281. background-color: #fff;
  282. z-index: 2;
  283. .btn{
  284. width: 48%;
  285. }
  286. }
  287. }
  288. /deep/ .u-popup__content{
  289. height: 70%;
  290. overflow-y: scroll;
  291. border-radius: 6px;
  292. }
  293. .popupShow {
  294. overflow: hidden;
  295. position: fixed;
  296. }
  297. </style>