edit.vue 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. <template>
  2. <view>
  3. <view class="add_page">
  4. <u-navbar class="nav-bar" title="商品入库" :autoBack="true" :placeholder="true" v-hideNav>
  5. <view class="u-nav-slot" slot="right">
  6. <u-checkbox-group v-model="continuousWarehousing" placement="column">
  7. <u-checkbox label="连续入库" name="1"></u-checkbox>
  8. </u-checkbox-group>
  9. </view>
  10. </u-navbar>
  11. <view class="form_list">
  12. <u--form labelPosition="top" :model="formData" :rules="rules" ref="addForm" labelWidth="100%">
  13. <u-form-item borderBottom class="u-form-item-col">
  14. <u--textarea v-model="recognitionContent" placeholder='品牌:-
  15. 来源:-
  16. 实价:-
  17. 型号:-
  18. 编码:-
  19. 日期:-
  20. 备注:-
  21. 付款方式:-' confirmType="done" height="170" :maxlength="-1">
  22. </u--textarea>
  23. <view class="btn_group_recognition">
  24. <u-button text="清除" @click="clearRecognitionContent()"></u-button>
  25. <u-button text="粘贴识别" type="primary"
  26. @click="handlePasteRecognition(recognitionContent)"></u-button>
  27. </view>
  28. </u-form-item>
  29. <u-form-item label="商品图片" required prop="goodPicFileList" borderBottom>
  30. <view class="imgs_scroll">
  31. <ImgsRowScroll v-if="formData.goodPicFileList.length > 0" :isShowDeleteIcon="true"
  32. @deleteImgInfo="getDeleteGoodPicInfo" imgMode="aspectFill" :totalWidth="400"
  33. :images="formData.goodPicFileList" :previewEnabled="true" :imageWidth="150"
  34. :imageHeight="150"></ImgsRowScroll>
  35. <u-upload @afterRead="afterReadGoodPic" name="3" multiple :maxCount="9"
  36. :previewFullImage="true"></u-upload>
  37. </view>
  38. </u-form-item>
  39. <u-form-item label="商品描述(详细的描述让用户更好的了解您的产品)" required prop="desc" borderBottom>
  40. <u--textarea v-model="formData.desc" clearable placeholder="95新 WHZ19219H CHANEL香奈儿链条单肩包
  41. 21开 牛皮 尺寸25 4 15
  42. 配件中溯卡" count autoHeight maxlength="250" :height="150" confirmType="done"></u--textarea>
  43. </u-form-item>
  44. <u-form-item label="来源" prop="origin" borderBottom>
  45. <u--textarea v-model="formData.origin" clearable placeholder="请输入来源" count autoHeight maxlength="250" height="100" confirmType="done"></u--textarea>
  46. </u-form-item>
  47. <u-form-item label="商品分类" required prop="type" borderBottom>
  48. <TabSelect :tabList="typeList" :isClear="typeIsClear" @tabChange="handleTabChangeType"
  49. labelKey="dictLabel" valueKey="dictValue" :colNum="4" mode="single" :echoInfo="echoInfoType">
  50. </TabSelect>
  51. </u-form-item>
  52. <u-form-item label="品牌" required prop="dictLabel" class="u-form-item-row" borderBottom
  53. @click="showBrandList">
  54. <Cell :val="formData.dictLabel"></Cell>
  55. <BrandList ref="brandListRef" @selectedBrand="handleSelectedBrand"></BrandList>
  56. </u-form-item>
  57. <u-form-item label="系列" class="u-form-item-row" borderBottom>
  58. <u--input v-model="formData.series" placeholder="请输入" clearable border="none"></u--input>
  59. </u-form-item>
  60. <u-form-item label="型号" class="u-form-item-row" borderBottom>
  61. <u--input v-model="formData.model" placeholder="请输入" clearable border="none"></u--input>
  62. </u-form-item>
  63. <u-form-item label="机芯类型" class="u-form-item-row" borderBottom>
  64. <u--input v-model="formData.dialType" placeholder="请输入" clearable border="none"></u--input>
  65. </u-form-item>
  66. <u-form-item label="表壳材质" class="u-form-item-row" borderBottom>
  67. <u--input v-model="formData.caseMaterial" placeholder="请输入" clearable border="none"></u--input>
  68. </u-form-item>
  69. <u-form-item label="表盘直径" class="u-form-item-row" borderBottom>
  70. <u--input v-model="formData.dialDiameter" placeholder="请输入" clearable border="none"></u--input>
  71. </u-form-item>
  72. <u-form-item label="材质" class="u-form-item-row" borderBottom>
  73. <u--input v-model="formData.material" placeholder="请输入" clearable border="none"></u--input>
  74. </u-form-item>
  75. <u-form-item label="尺寸" class="u-form-item-row" borderBottom>
  76. <u--input v-model="formData.size" placeholder="请输入" clearable border="none"></u--input>
  77. </u-form-item>
  78. <u-form-item label="尺码" class="u-form-item-row" borderBottom>
  79. <u--input v-model="formData.yardage" placeholder="请输入" clearable border="none"></u--input>
  80. </u-form-item>
  81. <u-form-item label="商品成色" required prop="productCondition" borderBottom>
  82. <TabSelect :tabList="productConditionList" :isClear="productConditionIsClear"
  83. @tabChange="handleTabChangeProductCondition" :colNum="2" mode="single" :echoInfo="echoInfoProductCondition">
  84. </TabSelect>
  85. </u-form-item>
  86. <u-form-item label="细节图" borderBottom>
  87. <!-- <view class="detail_pic_container"> -->
  88. <!-- <view>
  89. <text class="tip">视频:</text>
  90. <ImgsRowScroll v-if="formData.detailVideoFileList.length > 0" :isShowDeleteIcon="true"
  91. @deleteVideoInfo="getDeleteDetailVideoInfo" imgMode="aspectFill" :totalWidth="400"
  92. :videos="formData.detailVideoFileList" :previewEnabled="true" :imageWidth="150"
  93. :imageHeight="150" accept="video"></ImgsRowScroll>
  94. <u-upload @afterRead="afterReadDeatilVideo" name="2" multiple :maxCount="10" accept="video"></u-upload>
  95. </view> -->
  96. <!-- <view> -->
  97. <!-- <text class="tip">图片:</text> -->
  98. <view class="imgs_scroll">
  99. <ImgsRowScroll v-if="formData.detailPicFileList.length > 0" :isShowDeleteIcon="true"
  100. @deleteImgInfo="getDeleteDetailPicInfo" imgMode="aspectFill" :totalWidth="400"
  101. :images="formData.detailPicFileList" :previewEnabled="true" :imageWidth="150"
  102. :imageHeight="150"></ImgsRowScroll>
  103. <u-upload @afterRead="afterReadDetailPic" name="1" multiple :maxCount="10"></u-upload>
  104. </view>
  105. <!-- </view> -->
  106. <!-- </view> -->
  107. </u-form-item>
  108. <u-form-item label="商品标题" borderBottom>
  109. <u--textarea v-model="formData.title" clearable :placeholder="titlePlaceholder" count autoHeight
  110. maxlength="50" height="100" confirmType="done"></u--textarea>
  111. </u-form-item>
  112. <u-form-item label="商品货号" class="u-form-item-row" borderBottom>
  113. <u--input v-model="formData.productNo" placeholder="请输入" clearable border="none"></u--input>
  114. </u-form-item>
  115. <u-form-item label="商品属性" required prop="productAttribute" borderBottom>
  116. <TabSelect :tabList="productAttributeList" :colNum="4" mode="single"
  117. :isClear="productAttributeIsClear" @tabChange="handleTabChangeProductAttribute"
  118. :echoInfo="echoInfoProductAttribute">
  119. </TabSelect>
  120. </u-form-item>
  121. <u-form-item label="库存数量" required prop="stock" class="u-form-item-row" borderBottom>
  122. <u--input v-model="formData.stock" placeholder="请输入" clearable border="none"
  123. type="number"></u--input>
  124. </u-form-item>
  125. <u-form-item label="官方指导价" required prop="price" class="u-form-item-row" borderBottom>
  126. <u--input v-model="formData.price" placeholder="请输入" clearable border="none"></u--input>
  127. </u-form-item>
  128. <u-form-item label="总成本价" class="u-form-item-row" borderBottom v-if="isWareHouser">
  129. <u--input v-model="formData.costPrice" placeholder="请输入" clearable border="none"></u--input>
  130. </u-form-item>
  131. <u-form-item label="同行价格" class="u-form-item-row" borderBottom v-if="isWareHouser">
  132. <u--input v-model="formData.peerPrice" placeholder="请输入" clearable border="none"></u--input>
  133. </u-form-item>
  134. <u-form-item label="实价" class="u-form-item-row" borderBottom>
  135. <u--input v-model="formData.actualPrice" placeholder="请输入" clearable border="none" type="number" @blur="handleBlurActualPrice"></u--input>
  136. </u-form-item>
  137. <u-form-item label="代理价格" class="u-form-item-row" borderBottom>
  138. <u--input v-model="formData.agentPrice" placeholder="请输入" clearable border="none"></u--input>
  139. </u-form-item>
  140. <u-form-item label="销售价格" class="u-form-item-row" borderBottom v-if="isWareHouser">
  141. <u--input v-model="formData.salePrice" placeholder="请输入" clearable border="none"></u--input>
  142. </u-form-item>
  143. <u-form-item label="商品位置" class="u-form-item-row" borderBottom>
  144. <u--input v-model="formData.productPosition" placeholder="请输入" clearable
  145. border="none"></u--input>
  146. </u-form-item>
  147. <u-form-item label="手表年份" class="u-form-item-row" borderBottom>
  148. <u--input v-model="formData.watchYear" placeholder="请输入" clearable border="none"></u--input>
  149. </u-form-item>
  150. <u-form-item label="鉴定人员" class="u-form-item-row" borderBottom @click="identifyingPersonClick">
  151. <Cell :val="formData.identifyingPerson" :isDelete="true"
  152. @handleClear="clear('identifyingPerson')"></Cell>
  153. <PersonPicker ref="identifyingPersonPickerRef" title="请选择鉴定人员"
  154. @selectPerson="handleSelectIdentifyingPerson"></PersonPicker>
  155. </u-form-item>
  156. <u-form-item label="是否入库" borderBottom required prop="stockStatus">
  157. <TabSelect :tabList="stockStatusList" :colNum="2" mode="single" :isClear="stockStatusIsClear" :echoInfo="echoInfoStockStatus"
  158. @tabChange="handleTabChangeStockStatus"></TabSelect>
  159. </u-form-item>
  160. <u-form-item label="回收类型" borderBottom>
  161. <TabSelect :tabList="recycleTypeList" :colNum="4" mode="single" :isClear="recycleTypeIsClear" :echoInfo="echoInfoRecycleType"
  162. @tabChange="handleTabChangeRecycleType">
  163. </TabSelect>
  164. </u-form-item>
  165. <u-form-item label="标签" borderBottom>
  166. <TabSelect :tabList="labelList" :colNum="5" mode="single" :isClear="labelIsClear" :echoInfo="echoInfoLabel"
  167. @tabChange="handleTabChangeLabel">
  168. </TabSelect>
  169. </u-form-item>
  170. <u-form-item label="回收人员" class="u-form-item-row" borderBottom @click="recyclePersonClick">
  171. <!-- <u--input v-model="formData.recyclePerson" disabledColor="#fff" disabled clearable
  172. border="none"></u--input> -->
  173. <Cell :val="formData.recyclePerson" :isDelete="true" @handleClear="clear('recyclePerson')">
  174. </Cell>
  175. <PersonPicker ref="recyclePersonPickerRef" title="请选择回收人员"
  176. @selectPerson="handleSelectRecyclePerson"></PersonPicker>
  177. </u-form-item>
  178. <u-form-item label="回收留底图" borderBottom>
  179. <view class="recycle_bottom_desc">
  180. <u--textarea v-model="formData.recycleBottomDesc" clearable count autoHeight maxlength="250"
  181. height="100" confirmType="done"></u--textarea>
  182. <view class="imgs_scroll">
  183. <ImgsRowScroll v-if="formData.recycleBottomFileList.length > 0" :isShowDeleteIcon="true"
  184. @deleteImgInfo="getDeleteRecycleBottomPicInfo" imgMode="aspectFill"
  185. :totalWidth="400" :images="formData.recycleBottomFileList" :previewEnabled="true"
  186. :imageWidth="150" :imageHeight="150"></ImgsRowScroll>
  187. <u-upload @afterRead="afterReadRecycleBottom" name="1" multiple :maxCount="1"
  188. accept="image"></u-upload>
  189. </view>
  190. </view>
  191. </u-form-item>
  192. <u-form-item label="回收时间" required prop="recycleTime" class="u-form-item-row" borderBottom
  193. @click="clickRecycleTimeRow">
  194. <Cell :val="formData.recycleTime"></Cell>
  195. <u-datetime-picker @confirm="confirmRecycleTime" @close="closeRecycleTimePicker"
  196. @cancel="closeRecycleTimePicker" :show="recycleTimeShow" v-model="formData.recycleTime"
  197. mode="date"></u-datetime-picker>
  198. </u-form-item>
  199. <u-form-item label="独立编码" class="u-form-item-row" borderBottom>
  200. <u--input v-model="formData.indentifyCode" placeholder="请输入" clearable border="none"></u--input>
  201. </u-form-item>
  202. <u-form-item label="适用人群" class="u-form-item-row" borderBottom>
  203. <u-radio-group v-model="formData.targetAudience" placement="row">
  204. <u-radio activeColor="#3c9cff" name="general" label="通用"></u-radio>
  205. <u-radio activeColor="#3c9cff" name="man" label="男"></u-radio>
  206. <u-radio activeColor="#3c9cff" name="woman" label="女"></u-radio>
  207. </u-radio-group>
  208. </u-form-item>
  209. <u-form-item label="商品保卡" class="u-form-item-row" borderBottom>
  210. <u-radio-group v-model="formData.productCard" placement="row">
  211. <u-radio activeColor="#3c9cff" name="has" label="有保卡"></u-radio>
  212. <u-radio activeColor="#3c9cff" name="no" label="无保卡"></u-radio>
  213. </u-radio-group>
  214. </u-form-item>
  215. <u-form-item label="保卡年份" class="u-form-item-row" borderBottom
  216. v-if="formData.productCard === 'has'">
  217. <u--input v-model="formData.cardYear" placeholder="不填写默认空白保卡" clearable
  218. border="none"></u--input>
  219. </u-form-item>
  220. <u-form-item label="保卡图片或独立编码照片留底(仅内部人员可见)" borderBottom>
  221. <view class="imgs_scroll">
  222. <ImgsRowScroll v-if="formData.productCardPicFileList.length > 0" :isShowDeleteIcon="true"
  223. @deleteImgInfo="getDeleteProductCardPicInfo" imgMode="aspectFill" :totalWidth="400"
  224. :images="formData.productCardPicFileList" :previewEnabled="true" :imageWidth="150"
  225. :imageHeight="150"></ImgsRowScroll>
  226. <u-upload @afterRead="afterReadProductCardPic" name="3" multiple :maxCount="9"
  227. :previewFullImage="true"></u-upload>
  228. </view>
  229. </u-form-item>
  230. <u-form-item label="商品标签" class="u-form-item-row" borderBottom>
  231. <u--input v-model="formData.productTag" placeholder="请输入" clearable border="none"></u--input>
  232. </u-form-item>
  233. <u-form-item label="商品附件" class="u-form-item-row" borderBottom>
  234. <u--input v-model="formData.productAttachment" placeholder="请输入" clearable
  235. border="none"></u--input>
  236. </u-form-item>
  237. <u-form-item label="备注(仅内部人员可见)" borderBottom>
  238. <view class="recycle_bottom_desc">
  239. <u--textarea v-model="formData.productDesc" clearable count autoHeight maxlength="250"
  240. height="100" confirmType="done"></u--textarea>
  241. <view class="imgs_scroll">
  242. <ImgsRowScroll v-if="formData.productDescPicFileList.length > 0"
  243. :isShowDeleteIcon="true" @deleteImgInfo="getDeleteProductDescPicInfo"
  244. imgMode="aspectFill" :totalWidth="400" :images="formData.productDescPicFileList"
  245. :previewEnabled="true" :imageWidth="150" :imageHeight="150"></ImgsRowScroll>
  246. <u-upload @afterRead="afterReadProductDescPic" name="1" multiple :maxCount="1"
  247. accept="image"></u-upload>
  248. </view>
  249. </view>
  250. </u-form-item>
  251. <u-form-item label="付款方式">
  252. <TabSelect :tabList="paymentTabList" :echoInfo="echoInfoPayType" :colNum="4" mode="single"
  253. :isClear="payTypeIsClear" @tabChange="handlePayTypeTabChange">
  254. </TabSelect>
  255. </u-form-item>
  256. </u--form>
  257. </view>
  258. </view>
  259. <view :class="['btn_group', {'col-2': formData.stockStatus == '1'}]">
  260. <u-button plain type="primary" @click="submitForm('onlyIn')">保存</u-button>
  261. <u-button type="primary" @click="submitForm('inAndUp')" v-if="formData.stockStatus == '1'">入库并上架</u-button>
  262. </view>
  263. </view>
  264. </template>
  265. <script>
  266. import TabSelect from '@/components/custom-tab-select/index.vue'
  267. import Cell from '@/components/custom-cell/index.vue'
  268. import BrandList from '@/components/brand-list/index.vue'
  269. import ImgsRowScroll from '@/components/imgs-row-scroll/index.vue'
  270. import PersonPicker from '@/components/person-picker/index.vue'
  271. import { permissionCheck,getRoles } from '@/utils/util.js'
  272. import { productConditionList,productAttributeList,stockStatusList,recycleTypeList,labelList,paymentTabList } from '../js/public.js'
  273. export default {
  274. components: {
  275. TabSelect,
  276. Cell,
  277. BrandList,
  278. ImgsRowScroll,
  279. PersonPicker
  280. },
  281. data() {
  282. return {
  283. checkboxValue: [''],
  284. recognitionContent: '',
  285. formData: {
  286. goodPicFileList: [],//商品图片
  287. desc: '',
  288. origin: '',
  289. type: '1',
  290. dictLabel: '艾美',
  291. dictValue: '88',
  292. series: '',
  293. model: '',
  294. dialType: '',
  295. caseMaterial: '',
  296. dialDiameter: '',
  297. material: '',
  298. size: '',
  299. yardage: '',
  300. price: 0,
  301. productCondition: '1',
  302. detailPicFileList: [],//细节图片
  303. // detailVideoFileList:[],
  304. title:'',
  305. productNo: '',
  306. productAttribute: '1',
  307. stock: 1,
  308. costPrice: '',
  309. peerPrice: '',
  310. actualPrice: '',
  311. agentPrice: '',
  312. salePrice: '',
  313. productPosition: '',
  314. watchYear: '',
  315. identifyingPerson: '',
  316. identifyingPersonId: '',
  317. stockStatus: '0',
  318. recycleType: '',
  319. recyclePerson: '',
  320. recyclePersonId: '',
  321. recycleBottomDesc: '',
  322. recycleBottomFileList: [],//回收留底图
  323. recycleTime: this.$dayjs().format('YYYY-MM-DD'),
  324. indentifyCode: '',
  325. targetAudience: '',
  326. productCard: '',
  327. cardYear: '',
  328. productCardPicFileList: [],//商品保卡图片或独立编码照片留底
  329. productTag: '',
  330. productAttachment: '',
  331. productDesc: '',
  332. productDescPicFileList: [],//商品备注图片
  333. payType: '',
  334. },
  335. continuousWarehousing: [],//是否连续入库 1:是 0:否
  336. rules: {
  337. goodPicFileList: [
  338. { required: true, message: '请上传商品图片' },
  339. ],
  340. desc: [
  341. { required: true, message: '请输入商品描述', trigger: ['blur', 'change'] },
  342. ],
  343. type: [
  344. { required: true, message: '请选择商品分类', trigger: ['blur', 'change'] },
  345. ],
  346. dictLabel: [
  347. { required: true, message: '请选择品牌', trigger: ['blur', 'change'] },
  348. ],
  349. productCondition: [
  350. { required: true, message: '请选择商品成色', trigger: ['blur', 'change'] },
  351. ],
  352. productAttribute: [
  353. { required: true, message: '请选择商品属性', trigger: ['blur', 'change'] },
  354. ],
  355. stock: [
  356. { required: true, message: '请输入库存数量' }
  357. ],
  358. price: [
  359. { required: true, message: '请输入官方指导价' }
  360. ],
  361. stockStatus: [
  362. { required: true, message: '请选择是否入库', trigger: [ 'change'] },
  363. ],
  364. recycleTime: [
  365. { required: true, message: '请选择回收时间', trigger: ['blur', 'change'] },
  366. ],
  367. },
  368. recycleTimeShow: false,
  369. titlePlaceholder: '如不填,自动截取商品描述前50字',
  370. typeList: [],
  371. typeIsClear: false,//商品分类是否清空
  372. productConditionIsClear: false,//商品成色是否清空
  373. productAttributeIsClear: false,//商品属性是否清空
  374. recycleTypeIsClear: false,//回收类型是否清空
  375. stockStatusIsClear: false,//是否入库是否清空
  376. labelIsClear: false,//商品标签是否清空
  377. payTypeIsClear: false,//付款方式是否清空
  378. echoInfoPayType: '',//付款方式识别回显
  379. echoInfoRecycleType:'',//入库回显的时候 回收类型回显
  380. echoInfoLabel:'',//入库回显的时候 商品标签回显
  381. echoInfoType:'',//入库回显的时候 类型回显
  382. echoInfoProductAttribute:'',//入库回显的时候 商品属性回显
  383. echoInfoProductCondition:'',//入库回显的时候 商品成色回显
  384. echoInfoStockStatus:'',//入库回显的时候 是否入库回显
  385. isWareHouser: permissionCheck('WAREHOUSER',false),
  386. formType: '',//表单类型 add:新增 edit:编辑
  387. xhlSystemSetList: [],//系统设置-列表
  388. productConditionList:productConditionList,
  389. productAttributeList: productAttributeList,
  390. stockStatusList: stockStatusList,
  391. recycleTypeList: recycleTypeList,
  392. labelList: labelList,
  393. paymentTabList: paymentTabList,
  394. }
  395. },
  396. onLoad(options) {
  397. this.getTypeList();
  398. this.getXhlSystemSetList()
  399. this.$nextTick(async()=>{
  400. this.formType = options.formType
  401. if(options.formType == 'add'){
  402. this.clearForm()
  403. }else if(options.formType == 'edit'){
  404. const res = await uni.$u.api.wareHouseDetail({
  405. id: options.id,
  406. userId: this.$store.state.user.userInfo.userId,
  407. })
  408. this.formData = res.data
  409. this.formData.recycleTime = this.$dayjs(res.data.recycleTime).format('YYYY-MM-DD') || ''
  410. this.echoInfoType = res.data.type || '1'//商品分类回显
  411. this.formData.type = res.data.type || '1'//商品分类校验
  412. this.echoInfoProductAttribute = res.data.productAttribute || '1'//商品属性回显
  413. this.formData.productAttribute = res.data.productAttribute || '1'//商品属性校验
  414. this.echoInfoProductCondition = res.data.productCondition || '1'//商品成色回显
  415. this.formData.productCondition = res.data.productCondition || '1'//商品成色校验
  416. this.echoInfoStockStatus = res.data.stockStatus || '0'//是否入库回显
  417. this.formData.stockStatus = res.data.stockStatus || '0'//是否入库校验
  418. this.formData.stock = res.data.stock ? res.data.stock : 1//入库数量校验
  419. this.formData.price = res.data.price || 0//官方指导价校验
  420. this.echoInfoPayType = res.data.payType//付款方式回显
  421. this.echoInfoRecycleType = res.data.recycleType//回收类型回显
  422. this.echoInfoLabel = res.data.label//商品标签回显
  423. this.recognitionContent = `品牌:${res.data.dictLabel || '-'}
  424. 来源:${res.data.origin || '-'}
  425. 实价:${res.data.actualPrice || '-'}
  426. 型号:${res.data.model || '-'}
  427. 编码:${res.data.indentifyCode || '-'}
  428. 日期:${res.data.recycleTime || '-'}
  429. 备注:${res.data.productDesc || '-'}
  430. 付款方式:${this.paymentTabList.find(item => item.value == res.data.payType)?.name || '-'}
  431. `
  432. }
  433. })
  434. },
  435. methods: {
  436. getXhlSystemSetList(){
  437. uni.$u.api.xhlSystemSetList({
  438. pageNum: 1,
  439. pageSize: 99,
  440. }).then(res => {
  441. this.xhlSystemSetList = res.rows || []
  442. })
  443. },
  444. handleBlurActualPrice() {
  445. if (this.formData.actualPrice) {
  446. const actualPrice = Number(this.formData.actualPrice)
  447. let obj = {}
  448. // 只要账号权限里面有销售权限,就按照销售的计算规则,没有就固定计算
  449. if(getRoles().includes('SALESMAN')){
  450. obj = this.xhlSystemSetList.find(item => item.agentType == 'SALESMAN') || {}
  451. }else{
  452. obj = {
  453. goodsRate: 0.003,
  454. goodsAmount: 500,
  455. }
  456. }
  457. this.formData.agentPrice = (actualPrice + actualPrice*obj.goodsRate + obj.goodsAmount).toFixed(2)
  458. }
  459. },
  460. getTypeList() {
  461. this.$getDicts("crm_form_category").then(res => {
  462. this.typeList = res
  463. })
  464. },
  465. // 提交表单
  466. submitForm(submitType) {
  467. if(!permissionCheck('WAREHOUSER')) return false
  468. this.$refs.addForm.validate().then((valid) => {
  469. if (valid) {
  470. if (this.formData.title == '') {
  471. this.formData.title = this.formData.desc.substring(0, 50);
  472. }
  473. this.formData.recycleTime = this.$dayjs(this.formData.recycleTime).format('YYYY-MM-DD')
  474. const data = {
  475. ...this.formData,
  476. submitType: submitType, //提交类型 onlyIn:仅入库/暂存入库 inAndUp:入库并上架
  477. continuousWarehousing: this.continuousWarehousing[0] || '0',//是否连续入库 1:是 0:否
  478. }
  479. if(this.formType == 'add'){
  480. uni.$u.api.wareHouseAdd(data).then(res => {
  481. uni.$u.toast('操作成功');
  482. if (data.continuousWarehousing == '0') {
  483. setTimeout(() => {
  484. uni.navigateBack({
  485. delta: 1
  486. });
  487. }, 1000);
  488. } else {
  489. this.clearForm();
  490. }
  491. }).catch(err => {
  492. uni.$u.toast(err);
  493. })
  494. }else if(this.formType == 'edit'){
  495. uni.$u.api.wareHouseUpdate(data).then(res => {
  496. uni.$u.toast('操作成功');
  497. if (data.continuousWarehousing == '0') {
  498. setTimeout(() => {
  499. uni.navigateBack({
  500. delta: 1
  501. });
  502. }, 1000);
  503. } else {
  504. this.clearForm();
  505. }
  506. }).catch(err => {
  507. uni.$u.toast(err);
  508. })
  509. }
  510. } else {
  511. console.log('表单校验不通过');
  512. }
  513. });
  514. },
  515. clearForm() {
  516. this.formData = {
  517. goodPicFileList: [],//商品图片
  518. desc: '',
  519. origin: '',
  520. type: '1',
  521. dictLabel: '艾美',
  522. dictValue: '88',
  523. series: '',
  524. model: '',
  525. dialType: '',
  526. caseMaterial: '',
  527. dialDiameter: '',
  528. material: '',
  529. size: '',
  530. yardage: '',
  531. price: 0,
  532. productCondition: '1',
  533. detailPicFileList: [],//细节图片
  534. // detailVideoFileList:[],
  535. productNo: '',
  536. productAttribute: '1',
  537. stock: 1,
  538. costPrice: '',
  539. samePrice: '',
  540. agentPrice: '',
  541. salePrice: '',
  542. productPosition: '',
  543. watchYear: '',
  544. identifyingPerson: '',
  545. identifyingPersonId: '',
  546. stockStatus: '0',
  547. recycleType: '',
  548. label: '',
  549. recyclePerson: '',
  550. recyclePersonId: '',
  551. recycleBottomDesc: '',
  552. recycleBottomFileList: [],//回收留底图
  553. recycleTime: this.$dayjs().format('YYYY-MM-DD'),
  554. indentifyCode: '',
  555. targetAudience: '',
  556. productCard: '',
  557. cardYear: '',
  558. productCardPicFileList: [],//商品保卡图片或独立编码照片留底
  559. productTag: '',
  560. productAttachment: '',
  561. productDesc: '',
  562. productDescPicFileList: [],//商品备注图片
  563. payType: '',
  564. }
  565. this.recycleTypeIsClear = true;
  566. this.payTypeIsClear = true;
  567. this.labelIsClear = true;
  568. this.echoInfoType = '1';//类型默认第一项
  569. this.echoInfoProductCondition = '1';//商品成色默认第一项
  570. this.echoInfoProductAttribute = '1';//商品属性默认第一项
  571. this.echoInfoStockStatus = '0';//是否入库默认第一项
  572. this.continuousWarehousing = [];
  573. this.$nextTick(()=>{
  574. this.$refs.addForm.resetFields();
  575. })
  576. },
  577. // 选择品牌
  578. handleSelectedBrand(info) {
  579. this.formData.dictLabel = info.dictLabel;
  580. this.formData.dictValue = info.dictValue;
  581. this.$refs.addForm.validateField('dictLabel');
  582. },
  583. // 显示品牌列表
  584. showBrandList() {
  585. this.$refs.brandListRef.showBrandList();
  586. },
  587. // 清空输入框
  588. clear(key) {
  589. // 品牌
  590. if (key == 'dictLabel') {
  591. this.formData.dictLabel = '';
  592. this.formData.dictValue = '';
  593. return;
  594. }
  595. // 鉴定人
  596. if (key == 'identifyingPerson') {
  597. this.formData.identifyingPerson = '';
  598. this.formData.identifyingPersonId = '';
  599. return;
  600. }
  601. // 回收人
  602. if (key == 'recyclePerson') {
  603. this.formData.recyclePerson = '';
  604. this.formData.recyclePersonId = '';
  605. return;
  606. }
  607. this.formData[key] = '';
  608. },
  609. // 商品分类
  610. handleTabChangeType(e) {
  611. this.formData.type = e;
  612. this.$refs.addForm.validateField('type')
  613. },
  614. // 商品成色
  615. handleTabChangeProductCondition(e) {
  616. this.formData.productCondition = e;
  617. this.$refs.addForm.validateField('productCondition')
  618. },
  619. // 商品属性
  620. handleTabChangeProductAttribute(e) {
  621. this.formData.productAttribute = e;
  622. this.$refs.addForm.validateField('productAttribute')
  623. },
  624. // 是否入库
  625. handleTabChangeStockStatus(e) {
  626. this.formData.stockStatus = e;
  627. },
  628. // 回收类型
  629. handleTabChangeRecycleType(e) {
  630. this.formData.recycleType = e;
  631. },
  632. // 商品标签
  633. handleTabChangeLabel(e) {
  634. this.formData.label = e;
  635. },
  636. // 付款方式
  637. handlePayTypeTabChange(e) {
  638. this.formData.payType = e;
  639. },
  640. // 打开回收时间选择器
  641. clickRecycleTimeRow() {
  642. this.recycleTimeShow = true;
  643. },
  644. // 确认回收时间
  645. confirmRecycleTime(val) {
  646. this.$nextTick(() => {
  647. this.formData.recycleTime = this.$dayjs(val.value).format('YYYY-MM-DD');
  648. this.recycleTimeShow = false;
  649. })
  650. },
  651. // 关闭回收时间选择器
  652. closeRecycleTimePicker(val) {
  653. this.recycleTimeShow = false;
  654. },
  655. // 打开鉴定人选择器
  656. identifyingPersonClick() {
  657. this.$refs.identifyingPersonPickerRef.open();
  658. },
  659. // 选择鉴定人
  660. handleSelectIdentifyingPerson(info) {
  661. this.formData.identifyingPerson = info.label;
  662. this.formData.identifyingPersonId = info.id;
  663. },
  664. // 打开回收人选择器
  665. recyclePersonClick() {
  666. this.$refs.recyclePersonPickerRef.open();
  667. },
  668. // 选择回收人
  669. handleSelectRecyclePerson(info) {
  670. this.formData.recyclePerson = info.label;
  671. this.formData.recyclePersonId = info.id;
  672. },
  673. // 新增商品图片
  674. async afterReadGoodPic(event) {
  675. event.file.forEach(item => {
  676. uni.$u.api.uploadFile(item.url).then((res) => {
  677. this.formData.goodPicFileList.push(res.data.url);
  678. uni.$u.toast("文件上传成功");
  679. }).catch(() => {
  680. uni.$u.toast("上传文件失败");
  681. })
  682. })
  683. },
  684. // 获取删除商品图片信息
  685. getDeleteGoodPicInfo(info) {
  686. this.formData.goodPicFileList = info.newImages
  687. },
  688. // 获取删除细节图片信息
  689. getDeleteDetailPicInfo(info) {
  690. this.formData.detailPicFileList = info.newImages
  691. },
  692. // 新增细节图片
  693. async afterReadDetailPic(event) {
  694. event.file.forEach(item => {
  695. uni.$u.api.uploadFile(item.url).then((res) => {
  696. this.formData.detailPicFileList.push(res.data.url);
  697. uni.$u.toast("文件上传成功");
  698. }).catch(() => {
  699. uni.$u.toast("上传文件失败");
  700. })
  701. })
  702. },
  703. // 获取删除回收留底图信息
  704. getDeleteRecycleBottomPicInfo(info) {
  705. this.formData.recycleBottomFileList = info.newImages
  706. },
  707. // 新增回收留底图
  708. async afterReadRecycleBottom(event) {
  709. event.file.forEach(item => {
  710. uni.$u.api.uploadFile(item.url).then((res) => {
  711. this.formData.recycleBottomFileList.push(res.data.url);
  712. uni.$u.toast("文件上传成功");
  713. }).catch(() => {
  714. uni.$u.toast("上传文件失败");
  715. })
  716. })
  717. },
  718. // 删除商品保卡图片或独立编码照片留底
  719. getDeleteProductCardPicInfo(info) {
  720. this.formData.productCardPicFileList = info.newImages
  721. },
  722. // 新增商品保卡图片或独立编码照片留底
  723. async afterReadProductCardPic(event) {
  724. event.file.forEach(item => {
  725. uni.$u.api.uploadFile(item.url).then((res) => {
  726. this.formData.productCardPicFileList.push(res.data.url);
  727. uni.$u.toast("文件上传成功");
  728. }).catch(() => {
  729. uni.$u.toast("上传文件失败");
  730. })
  731. })
  732. },
  733. // 获取删除商品备注图片信息
  734. getDeleteProductDescPicInfo(info) {
  735. this.formData.productDescPicFileList = info.newImages
  736. },
  737. // 新增商品备注图片
  738. async afterReadProductDescPic(event) {
  739. event.file.forEach(item => {
  740. uni.$u.api.uploadFile(item.url).then((res) => {
  741. this.formData.productDescPicFileList.push(res.data.url);
  742. uni.$u.toast("文件上传成功");
  743. }).catch(() => {
  744. uni.$u.toast("上传文件失败");
  745. })
  746. })
  747. },
  748. async handlePasteRecognition(text) {
  749. // 品牌:浪琴
  750. // 来源:【麒麟】私信-杰3-3
  751. // 实价:6500
  752. // 型号:L2.257.5.89.7
  753. // 编码:52356065
  754. // 日期:2021-11-09
  755. // 备注:全套
  756. // 付款方式:微信
  757. if (!text) {
  758. return;
  759. }
  760. try {
  761. if (!text) return {};
  762. const result = {};
  763. // 支持中文冒号和英文冒号
  764. const lines = text.split(/[\n\r]+/);
  765. lines.forEach(line => {
  766. const lineStr = line.trim();
  767. if (!lineStr) return;
  768. // 尝试中文冒号
  769. let separatorIndex = lineStr.indexOf(':');
  770. // 如果没有中文冒号,尝试英文冒号
  771. if (separatorIndex === -1) {
  772. separatorIndex = lineStr.indexOf(':');
  773. }
  774. if (separatorIndex > 0) {
  775. const key = lineStr.substring(0, separatorIndex).trim();
  776. const value = lineStr.substring(separatorIndex + 1).trim();
  777. result[key] = value;
  778. }
  779. });
  780. if (result['品牌']) {
  781. this.formData.dictLabel = result['品牌'];
  782. }
  783. if (result['来源']) {
  784. this.formData.origin = result['来源'];
  785. }
  786. if (result['实价']) {
  787. this.formData.actualPrice = result['实价'];
  788. }
  789. if (result['型号']) {
  790. this.formData.model = result['型号'];
  791. }
  792. if (result['编码']) {
  793. this.formData.indentifyCode = result['编码'];
  794. }
  795. if (result['日期']) {
  796. this.formData.recycleTime = result['日期'];
  797. }
  798. if (result['备注']) {
  799. this.formData.productDesc = result['备注'];
  800. }
  801. if (result['付款方式']) {
  802. this.getPaymentType(result['付款方式'])
  803. this.formData.payType = result['付款方式'];
  804. }
  805. // return result;
  806. } catch (e) {
  807. uni.$u.toast("文本识别异常");
  808. }
  809. },
  810. // 清空识别内容
  811. clearRecognitionContent() {
  812. this.recognitionContent = '';
  813. },
  814. // 识别内容 回显付款方式
  815. getPaymentType(val) {
  816. let arr = []
  817. this.paymentTabList.filter(item => {
  818. if (item.name == val) arr.push(item.value)
  819. })
  820. if (arr.length > 0) {
  821. this.echoInfoPayType = arr[0]
  822. }
  823. }
  824. }
  825. }
  826. </script>
  827. <style lang="scss" scoped>
  828. @import '../styles/edit.scss';
  829. </style>