productSearch.vue 9.8 KB

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