productSearch.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="productSearch-wrap">
  3. <u-popup v-model="isShow" class="search-popup" mode="right" @close="isShow=false" length="85%">
  4. <u-form class="form-content" :model="form" ref="uForm" label-width="180">
  5. <u-form-item label="车架号(VIN)" prop="vinCode" class="form-item">
  6. <u-input v-model.trim="form.vinCode" :maxlength="17" placeholder="请输入车架号" input-align="right" />
  7. <u-upload :custom-btn="true" ref="uUpload" :show-upload-list="false" :action="action" :form-data="{savePathType: 'local'}" @on-success="uploadSuccess" :max-size="2 * 1024 * 1024">
  8. <template v-slot:addBtn>
  9. <view class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
  10. <u-icon name="camera-fill" color="#c8c0cc" size="34" style="margin-left: 14upx;"></u-icon>
  11. </view>
  12. </template>
  13. </u-upload>
  14. </u-form-item>
  15. <u-form-item label="产品编码" prop="productCode" class="form-item">
  16. <u-input v-model.trim="form.productCode" placeholder="请输入产品编码" input-align="right" />
  17. </u-form-item>
  18. <u-form-item label="原厂编码" prop="productOrigCode" class="form-item">
  19. <u-input v-model.trim="form.productOrigCode" placeholder="请输入原厂编码" input-align="right" />
  20. </u-form-item>
  21. <u-form-item label="产品名称" prop="productName" class="form-item">
  22. <u-input v-model.trim="form.productName" placeholder="请输入产品名称" input-align="right" />
  23. </u-form-item>
  24. <u-form-item label="产品品牌" prop="productBrandSn" class="form-item">
  25. <u-input v-model="brandName" @click="brandModal=true" @clear="brandClean" clearable type="select" placeholder="请选择产品品牌" input-align="right" />
  26. </u-form-item>
  27. <u-form-item label="产品分类" prop="productTypeSn" class="form-item">
  28. <u-input v-model="productTypeNameArr" @click="showTypeModal=true" @clear="typeClean" type="select" clearable placeholder="请选择产品分类" input-align="right" />
  29. </u-form-item>
  30. <u-form-item label="仓库" prop="warehouseSn" class="form-item">
  31. <u-input v-model="warehouseName" @click="warehouseModal=true" @clear="clearWarehouse" type="select" clearable placeholder="请选择仓库" class="form-item-inp" input-align="right" />
  32. </u-form-item>
  33. <u-form-item label="成本价">
  34. <template v-slot:right>
  35. <u-switch v-model="form.cost"></u-switch>
  36. </template>
  37. </u-form-item>
  38. <u-form-item label="市级价">
  39. <template v-slot:right>
  40. <u-switch v-model="form.cityPrice"></u-switch>
  41. </template>
  42. </u-form-item>
  43. </u-form>
  44. <view class="uni-list-btns">
  45. <u-button class="handle-btn" size="medium" hover-class="none" shape="circle" @click="resetForm">重置</u-button>
  46. <u-button class="handle-btn search-btn" size="medium" shape="circle" hover-class="none" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  47. </view>
  48. </u-popup>
  49. <!-- 产品品牌 -->
  50. <productBrand :openModal="brandModal" :itemSn="form.productBrandSn" @choose="brandChoose" @clean="brandClean" @close="brandModal=false" />
  51. <!-- 产品分类 -->
  52. <productType :openModal="showTypeModal" :nowData="nowData" @choose="typeChoose" @close="showTypeModal=false" />
  53. <!-- 选择收款方式 -->
  54. <u-picker v-model="warehouseModal" @confirm="warehouseChange" :range="warehouseList" range-key="name" mode="selector"></u-picker>
  55. </view>
  56. </template>
  57. <script>
  58. import productBrand from '@/pages/common/productBrand.vue'
  59. import productType from '@/pages/common/productType.vue'
  60. import { warehouseAllList, vinCodeParse } from '@/api/sales'
  61. const baseUrl = getApp({ allowDefault: true }).globalData.baseUrl
  62. export default{
  63. components: { productBrand, productType },
  64. props: {
  65. openModal: { // 弹框显示状态
  66. type: Boolean,
  67. default: false
  68. },
  69. defaultParams: { // 默认查询条件
  70. type: Object,
  71. default: () => {
  72. return null
  73. }
  74. }
  75. },
  76. data(){
  77. return{
  78. isShow: this.openModal,
  79. form: {
  80. vinCode: '',
  81. productCode: '', // 产品编码
  82. productName: '', // 产品名称
  83. productOrigCode: '', // 原厂编码
  84. productBrandSn: undefined, // 产品品牌
  85. productTypeSn1: undefined, // 产品分类1
  86. productTypeSn2: undefined, // 产品分类2
  87. productTypeSn3: undefined, // 产品分类3
  88. warehouseSn: undefined, // 仓库
  89. cost: false, // 成本价
  90. cityPrice: false, // 市级价
  91. },
  92. customBtnStyle: { // 自定义按钮样式
  93. borderColor: this.$config('primaryColor'),
  94. backgroundColor: this.$config('primaryColor'),
  95. color: '#fff'
  96. },
  97. warehouseName: '',
  98. warehouseModal: false,
  99. warehouseList: [],
  100. brandModal: false,
  101. brandName: '',
  102. showTypeModal: false,
  103. nowData: [],
  104. action: baseUrl + 'vinIdentify/ocr',
  105. }
  106. },
  107. computed: {
  108. productTypeNameArr: function() {
  109. let str = ''
  110. this.nowData.map(item => {
  111. str += item.productTypeName+' / '
  112. })
  113. return str ? str.substr(0, str.length-3) : ''
  114. }
  115. },
  116. mounted() {
  117. this.getWarehouse()
  118. },
  119. methods: {
  120. // 初始化数据
  121. init(){
  122. console.log(this.defaultParams)
  123. this.form.vinCode = this.defaultParams && this.defaultParams.vinCode || ''
  124. this.form.productCode = this.defaultParams && this.defaultParams.productCode || ''
  125. this.form.productName = this.defaultParams && this.defaultParams.productName || ''
  126. this.form.productOrigCode = this.defaultParams && this.defaultParams.productOrigCode || ''
  127. this.form.productBrandSn = this.defaultParams && this.defaultParams.productBrandSn || undefined
  128. this.form.productTypeSn1 = this.defaultParams && this.defaultParams.productTypeSn1 || undefined
  129. this.form.productTypeSn2 = this.defaultParams && this.defaultParams.productTypeSn2 || undefined
  130. this.form.productTypeSn3 = this.defaultParams && this.defaultParams.productTypeSn3 || undefined
  131. this.form.warehouseSn = this.defaultParams && this.defaultParams.warehouseSn || undefined
  132. this.form.cost = this.defaultParams && this.defaultParams.cost || false
  133. this.form.cityPrice = this.defaultParams && this.defaultParams.cityPrice || false
  134. this.brandName = this.defaultParams && this.defaultParams.brandName || ''
  135. this.nowData = this.defaultParams && this.defaultParams.nowData ? this.defaultParams.nowData : []
  136. this.warehouseName = this.defaultParams && this.defaultParams.warehouseName || ''
  137. },
  138. // 查询
  139. handleSearch() {
  140. let params = JSON.parse(JSON.stringify(this.form))
  141. let other = {
  142. brandName: this.brandName,
  143. nowData: this.nowData,
  144. warehouseName: this.warehouseName
  145. }
  146. this.$emit('refresh', Object.assign(params, other))
  147. this.isShow = false
  148. },
  149. // 重置
  150. resetForm() {
  151. this.warehouseName = ''
  152. this.nowData = []
  153. this.$refs.uForm.resetFields()
  154. this.$emit('refresh', {})
  155. this.isShow = false
  156. this.brandClean()
  157. this.typeClean()
  158. },
  159. uploadSuccess(res){
  160. if(res.status == 200){
  161. this.form.vinCode = res.data
  162. }else{
  163. this.toashMsg(res.message)
  164. }
  165. },
  166. // 选择品牌
  167. brandChoose(data){
  168. this.brandName = data.brandName
  169. this.form.productBrandSn = data.brandSn
  170. },
  171. // 清空品牌
  172. brandClean(){
  173. this.brandName = ''
  174. this.form.productBrandSn = undefined
  175. },
  176. // 选择分类
  177. typeChoose(obj){
  178. if(obj){
  179. this.nowData = obj
  180. this.form.productTypeSn1 = obj[0].productTypeSn
  181. this.form.productTypeSn2 = obj[1].productTypeSn
  182. this.form.productTypeSn3 = obj[2].productTypeSn
  183. }else{
  184. this.typeClean()
  185. }
  186. },
  187. // 清空分类
  188. typeClean(){
  189. this.nowData = []
  190. this.form.productTypeSn1 = undefined
  191. this.form.productTypeSn2 = undefined
  192. this.form.productTypeSn3 = undefined
  193. },
  194. // 清空仓库
  195. clearWarehouse(){
  196. this.warehouseName = ''
  197. this.form.warehouseSn = undefined
  198. },
  199. // 仓库 change
  200. warehouseChange(ind){
  201. this.form.warehouseSn = this.warehouseList[ind].warehouseSn || undefined
  202. this.warehouseName = this.warehouseList[ind].name || ''
  203. },
  204. // 仓库列表
  205. getWarehouse () {
  206. warehouseAllList().then(res => {
  207. if(res.status == 200 && res.data){
  208. this.warehouseList = res.data
  209. // 仓库有值时,匹配对应name
  210. if(this.defaultParams && (this.defaultParams.warehouseSn || this.defaultParams.warehouseSn==0)){
  211. this.warehouseList.map(item => {
  212. if(item.warehouseSn == this.defaultParams.warehouseSn){
  213. this.warehouseName = item.name
  214. }
  215. })
  216. }
  217. }else{
  218. this.warehouseList = []
  219. }
  220. })
  221. },
  222. },
  223. watch: {
  224. // 父页面传过来的弹框状态
  225. openModal (newValue, oldValue) {
  226. this.isShow = newValue
  227. },
  228. // 重定义的弹框状态
  229. isShow (newValue, oldValue) {
  230. if (!newValue) {
  231. this.$emit('close')
  232. }else{
  233. this.init()
  234. }
  235. }
  236. }
  237. }
  238. </script>
  239. <style lang="scss">
  240. .productSearch-wrap{
  241. .search-popup {
  242. .form-content {
  243. display: block;
  244. padding: 0 20upx;
  245. box-sizing: content-box;
  246. .form-item{
  247. .vin-box{
  248. margin-left: 14upx;
  249. position: relative;
  250. .vin-upload{
  251. position: absolute;
  252. right: 0;
  253. top: 0;
  254. }
  255. }
  256. }
  257. .form-item-inp{
  258. display: inline-block;
  259. width: 88%;
  260. vertical-align: top;
  261. }
  262. }
  263. .uni-list-btns {
  264. display: flex;
  265. padding: 20upx;
  266. margin-top: 100upx;
  267. .handle-btn {
  268. font-size: 28upx;
  269. margin: 0 30upx;
  270. width: 100%;
  271. flex: 1;
  272. }
  273. }
  274. }
  275. }
  276. </style>