productSearch.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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="产品编码" 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" @click="resetForm">重置</u-button>
  41. <u-button class="handle-btn search-btn" size="medium" 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.brandName = ''
  165. this.$refs.uForm.resetFields()
  166. this.$emit('refresh', {})
  167. this.isShow = false
  168. },
  169. uploadSuccess(res){
  170. console.log(res)
  171. if(res.status == 200){
  172. this.form.vinCode = res.data
  173. }else{
  174. this.toashMsg(res.message)
  175. }
  176. },
  177. // 选择品牌
  178. brandChoose(data){
  179. this.brandName = data.brandName
  180. this.form.productBrandSn = data.brandSn
  181. },
  182. // 清空品牌
  183. brandClean(){
  184. this.brandName = ''
  185. this.form.productBrandSn = undefined
  186. },
  187. // 选择分类
  188. typeChoose(obj){
  189. this.nowData = {
  190. data: obj.data,
  191. indArr: obj.indArr,
  192. nowInd: obj.nowInd
  193. }
  194. this.form.productTypeSn1 = this.nowData.data[0]&&this.nowData.data[0].productTypeSn ? this.nowData.data[0].productTypeSn : undefined
  195. this.form.productTypeSn2 = this.nowData.data[1]&&this.nowData.data[1].productTypeSn ? this.nowData.data[1].productTypeSn : undefined
  196. this.form.productTypeSn3 = this.nowData.data[2]&&this.nowData.data[2].productTypeSn ? this.nowData.data[2].productTypeSn : undefined
  197. },
  198. // 清空分类
  199. typeClean(){
  200. this.nowData = {
  201. data: [],
  202. indArr: [],
  203. nowInd: 0
  204. }
  205. this.form.productTypeSn1 = undefined
  206. this.form.productTypeSn2 = undefined
  207. this.form.productTypeSn3 = undefined
  208. },
  209. // 清空仓库
  210. clearWarehouse(){
  211. this.warehouseName = ''
  212. this.form.warehouseSn = undefined
  213. },
  214. // 仓库 change
  215. warehouseChange(ind){
  216. this.form.warehouseSn = this.warehouseList[ind].warehouseSn || undefined
  217. this.warehouseName = this.warehouseList[ind].name || ''
  218. },
  219. // 仓库列表
  220. getWarehouse () {
  221. warehouseAllList().then(res => {
  222. if(res.status == 200 && res.data){
  223. this.warehouseList = res.data
  224. // 仓库有值时,匹配对应name
  225. if(this.defaultParams && (this.defaultParams.warehouseSn || this.defaultParams.warehouseSn==0)){
  226. this.warehouseList.map(item => {
  227. if(item.warehouseSn == this.defaultParams.warehouseSn){
  228. this.warehouseName = item.name
  229. }
  230. })
  231. }
  232. }else{
  233. this.warehouseList = []
  234. }
  235. })
  236. },
  237. },
  238. watch: {
  239. // 父页面传过来的弹框状态
  240. openModal (newValue, oldValue) {
  241. this.isShow = newValue
  242. },
  243. // 重定义的弹框状态
  244. isShow (newValue, oldValue) {
  245. if (!newValue) {
  246. this.$emit('close')
  247. }else{
  248. this.init()
  249. }
  250. }
  251. }
  252. }
  253. </script>
  254. <style lang="scss">
  255. .productSearch-wrap{
  256. .search-popup {
  257. .form-content {
  258. display: block;
  259. padding: 0 20upx;
  260. box-sizing: content-box;
  261. .form-item{
  262. .vin-box{
  263. margin-left: 14upx;
  264. position: relative;
  265. .vin-upload{
  266. position: absolute;
  267. right: 0;
  268. top: 0;
  269. }
  270. }
  271. }
  272. .form-item-inp{
  273. display: inline-block;
  274. width: 88%;
  275. vertical-align: top;
  276. }
  277. }
  278. .uni-list-btns {
  279. display: flex;
  280. padding: 20upx;
  281. margin-top: 100upx;
  282. .handle-btn {
  283. font-size: 28upx;
  284. margin: 0 30upx;
  285. width: 100%;
  286. flex: 1;
  287. }
  288. }
  289. }
  290. }
  291. </style>