index.vue 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="商品分类" prop="cateId">
  5. <treeselect v-model="queryParams.cateId" style="width:205.4px" :options="categoryOptions" :normalizer="normalizer" placeholder="请选择分类" />
  6. </el-form-item>
  7. <el-form-item label="商品名称" prop="productName">
  8. <el-input
  9. v-model="queryParams.productName"
  10. placeholder="请输入商品名称"
  11. clearable
  12. size="small"
  13. @keyup.enter.native="handleQuery"
  14. />
  15. </el-form-item>
  16. <el-form-item label="商品编号" prop="barCode">
  17. <el-input
  18. v-model="queryParams.barCode"
  19. placeholder="请输入商品编号"
  20. clearable
  21. size="small"
  22. @keyup.enter.native="handleQuery"
  23. />
  24. </el-form-item>
  25. <el-form-item label="商品类型" prop="productType">
  26. <el-select v-model="queryParams.productType" placeholder="请选择商品类型" clearable size="small" >
  27. <el-option
  28. v-for="item in productTypeOptions"
  29. :key="item.dictValue"
  30. :label="item.dictLabel"
  31. :value="item.dictValue"
  32. />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="所属公司">
  36. <el-select style="width: 240px" v-model="companyId" multiple placeholder="请选择企业" clearable size="small" >
  37. <el-option
  38. v-for="item in companyOptions"
  39. :key="item.companyId"
  40. :label="item.companyName"
  41. :value="item.companyId"
  42. />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="所属店铺" v-if="this.isStores">
  46. <el-select style="width: 240px" v-model="queryParams.storeIds" placeholder="请选择店铺" clearable size="small" >
  47. <el-option
  48. v-for="item in storeOptions"
  49. :key="item.storeId"
  50. :label="item.storeName"
  51. :value="item.storeId"
  52. />
  53. </el-select>
  54. </el-form-item>
  55. <div v-if="this.isMedicalMall">
  56. <el-form-item label="审核状态">
  57. <el-select style="width: 240px" v-model="queryParams.isAudit" placeholder="请选择审核状态" size="small" >
  58. <el-option value="0" label="待审核" key="isAudit0">待审核</el-option>
  59. <el-option value="1" label="审核通过" key="isAudit1">审核通过</el-option>
  60. </el-select>
  61. </el-form-item>
  62. <el-form-item label="药品注册证书编号" prop="drugRegCertNo">
  63. <el-input
  64. v-model="queryParams.drugRegCertNo"
  65. placeholder="请输入药品注册证书编号"
  66. clearable
  67. size="small"
  68. />
  69. </el-form-item>
  70. <el-form-item label="通用名称" prop="commonName">
  71. <el-input
  72. v-model="queryParams.commonName"
  73. placeholder="请输入通用名称"
  74. clearable
  75. size="small"
  76. />
  77. </el-form-item>
  78. <el-form-item label="剂型" prop="dosageForm">
  79. <el-input
  80. v-model="queryParams.dosageForm"
  81. placeholder="请输入剂型"
  82. clearable
  83. size="small"
  84. />
  85. </el-form-item>
  86. <el-form-item label="单价" prop="unitPrice">
  87. <el-input
  88. v-model="queryParams.unitPrice"
  89. placeholder="请输入单价"
  90. clearable
  91. size="small"
  92. />
  93. </el-form-item>
  94. <el-form-item label="批号" prop="batchNumber">
  95. <el-input
  96. v-model="queryParams.batchNumber"
  97. placeholder="请输入批号"
  98. clearable
  99. size="small"
  100. />
  101. </el-form-item>
  102. <el-form-item label="上市许可持有人" prop="mah">
  103. <el-input
  104. v-model="queryParams.mah"
  105. placeholder="请输入上市许可持有人"
  106. clearable
  107. size="small"
  108. />
  109. </el-form-item>
  110. <el-form-item label="持有人地址" prop="mahAddress">
  111. <el-input
  112. v-model="queryParams.mahAddress"
  113. placeholder="请输入持有人地址"
  114. clearable
  115. size="small"
  116. />
  117. </el-form-item>
  118. <el-form-item label="生产企业" prop="manufacturer">
  119. <el-input
  120. v-model="queryParams.manufacturer"
  121. placeholder="请输入生产企业"
  122. clearable
  123. size="small"
  124. />
  125. </el-form-item>
  126. <el-form-item label="生产企业地址" prop="manufacturerAddress">
  127. <el-input
  128. v-model="queryParams.manufacturerAddress"
  129. placeholder="请输入生产企业地址"
  130. clearable
  131. size="small"
  132. />
  133. </el-form-item>
  134. <el-form-item label="功能主治" prop="indications">
  135. <el-input
  136. v-model="queryParams.indications"
  137. placeholder="请输入功能主治"
  138. clearable
  139. size="small"
  140. />
  141. </el-form-item>
  142. <el-form-item label="用法用量" prop="dosage">
  143. <el-input
  144. v-model="queryParams.dosage"
  145. placeholder="请输入用法用量"
  146. clearable
  147. size="small"
  148. />
  149. </el-form-item>
  150. <el-form-item label="不良反应" prop="adverseReactions">
  151. <el-input
  152. v-model="queryParams.adverseReactions"
  153. placeholder="请输入不良反应"
  154. clearable
  155. size="small"
  156. />
  157. </el-form-item>
  158. <el-form-item label="禁忌" prop="contraindications">
  159. <el-input
  160. v-model="queryParams.contraindications"
  161. placeholder="请输入禁忌"
  162. clearable
  163. size="small"
  164. />
  165. </el-form-item>
  166. <el-form-item label="注意事项" prop="precautions">
  167. <el-input
  168. v-model="queryParams.precautions"
  169. placeholder="请输入注意事项"
  170. clearable
  171. size="small"
  172. />
  173. </el-form-item>
  174. </div>
  175. <!-- <el-form-item label="状态" prop="isShow">
  176. <el-select style="width: 240px" v-model="queryParams.isShow" placeholder="请选择状态" clearable size="small" >
  177. <el-option
  178. v-for="item in isShowOptions"
  179. :key="item.dictValue"
  180. :label="item.dictLabel"
  181. :value="item.dictValue"
  182. />
  183. </el-select>
  184. </el-form-item> -->
  185. <el-form-item>
  186. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  187. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  188. </el-form-item>
  189. </el-form>
  190. <el-row :gutter="10" class="mb8">
  191. <el-col :span="1.5">
  192. <el-button
  193. type="primary"
  194. icon="el-icon-plus"
  195. size="mini"
  196. @click="handleAdd"
  197. v-hasPermi="['store:storeProduct:add']"
  198. >新增</el-button>
  199. </el-col>
  200. <el-col :span="1.5">
  201. <el-button
  202. type="success"
  203. icon="el-icon-edit"
  204. size="mini"
  205. :disabled="multiple"
  206. @click="handleUpdate"
  207. v-hasPermi="['store:storeProduct:edit']"
  208. >修改</el-button>
  209. </el-col>
  210. <el-col :span="1.5">
  211. <el-button
  212. type="danger"
  213. icon="el-icon-delete"
  214. size="mini"
  215. :disabled="multiple"
  216. @click="handleDelete"
  217. v-hasPermi="['store:storeProduct:remove']"
  218. >删除</el-button>
  219. </el-col>
  220. <el-col :span="1.5">
  221. <el-button
  222. type="info"
  223. plain
  224. icon="el-icon-upload2"
  225. size="mini"
  226. @click="handleImport"
  227. v-hasPermi="['store:storeProduct:import']"
  228. >导入</el-button>
  229. </el-col>
  230. <el-col :span="1.5">
  231. <el-button
  232. type="warning"
  233. icon="el-icon-download"
  234. size="mini"
  235. @click="handleExport"
  236. v-hasPermi="['store:storePayment:export']"
  237. >导出</el-button>
  238. </el-col>
  239. <el-col :span="1.5">
  240. <el-button
  241. type="success"
  242. icon="el-icon-edit"
  243. size="mini"
  244. :disabled="multiple"
  245. @click="bulkCopy"
  246. v-hasPermi="['store:storeProduct:bulkCopy']"
  247. >批量复制</el-button>
  248. </el-col>
  249. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  250. </el-row>
  251. <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
  252. <el-tab-pane label="出售中" name="1"></el-tab-pane>
  253. <el-tab-pane label="待上架" name="0"></el-tab-pane>
  254. </el-tabs>
  255. <el-table height="500" border v-loading="loading" :data="storeProductList" @selection-change="handleSelectionChange">
  256. <el-table-column type="selection" width="55" align="center" />
  257. <el-table-column label="ID" align="center" prop="productId" />
  258. <el-table-column label="商品图片" align="center" width="120">
  259. <template slot-scope="scope">
  260. <el-popover
  261. placement="right"
  262. title=""
  263. trigger="hover">
  264. <img slot="reference" :src="scope.row.image" width="100">
  265. <img :src="scope.row.image" style="max-width: 150px;">
  266. </el-popover>
  267. </template>
  268. </el-table-column>
  269. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  270. <el-table-column label="分类" align="center" prop="cateName" />
  271. <el-table-column label="所属公司" align="center" prop="companyName" />
  272. <el-table-column label="所属店铺" align="center" prop="storeName" v-if="this.isStores"/>
  273. <el-table-column label="售价" align="center" prop="price" >
  274. <template slot-scope="scope" >
  275. <span v-if="scope.row.price!=null">{{scope.row.price.toFixed(2)}}</span>
  276. </template>
  277. </el-table-column>
  278. <el-table-column label="原价" align="center" prop="otPrice" >
  279. <template slot-scope="scope" >
  280. <span v-if="scope.row.otPrice!=null">{{scope.row.otPrice.toFixed(2)}}</span>
  281. </template>
  282. </el-table-column>
  283. <el-table-column label="销量" align="center" prop="sales" />
  284. <el-table-column label="库存" align="center" prop="stock" />
  285. <el-table-column label="类型" align="center" prop="productType" >
  286. <template slot-scope="scope">
  287. <el-tag prop="productType" v-for="(item, index) in productTypeOptions" v-if="scope.row.productType==item.dictValue">{{item.dictLabel}}</el-tag>
  288. </template>
  289. </el-table-column>
  290. <el-table-column label="状态" align="center" prop="isShow" >
  291. <template slot-scope="scope">
  292. <el-tag :type="getStatusType(scope.row)" prop="status">
  293. {{ getStatusText(scope.row) }}
  294. </el-tag>
  295. </template>
  296. </el-table-column>
  297. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  298. <template slot-scope="scope">
  299. <el-button
  300. size="mini"
  301. type="text"
  302. icon="el-icon-edit"
  303. @click="handleUpdate(scope.row)"
  304. v-hasPermi="['store:storeProduct:edit']"
  305. >修改</el-button>
  306. <el-button
  307. size="mini"
  308. type="text"
  309. icon="el-icon-edit"
  310. @click="showOperLog(scope.row)"
  311. v-hasPermi="['store:storeProduct:list']"
  312. v-if="scope.row.isAudit===1"
  313. >审核记录</el-button>
  314. <el-button
  315. size="mini"
  316. type="text"
  317. icon="el-icon-delete"
  318. @click="handleDelete(scope.row)"
  319. v-hasPermi="['store:storeProduct:remove']"
  320. >删除</el-button>
  321. </template>
  322. </el-table-column>
  323. </el-table>
  324. <pagination
  325. v-show="total>0"
  326. :total="total"
  327. :page.sync="queryParams.pageNum"
  328. :limit.sync="queryParams.pageSize"
  329. @pagination="getList"
  330. />
  331. <el-dialog :title="title" :visible.sync="open1" width="580px" append-to-body>
  332. <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">
  333. <el-form-item label="商品状态" prop="status">
  334. <el-radio-group v-model="form1.isShow">
  335. <el-radio :label="item.dictValue" v-for="item in isShowOptions" >{{item.dictLabel}}</el-radio>
  336. </el-radio-group>
  337. </el-form-item>
  338. <el-form-item label="商城展示" prop="isDisplay">
  339. <el-radio-group v-model="form1.isDisplay">
  340. <el-radio :label="item.dictValue" v-for="item in isDisplayOptions" >{{item.dictLabel}}</el-radio>
  341. </el-radio-group>
  342. </el-form-item>
  343. <el-form-item label="所属公司" prop="companyId">
  344. <el-select style="width: 220px" filterable multiple v-model="form1.companyId" placeholder="请选择公司名" clearable size="small">
  345. <el-option
  346. v-for="item in companyOptions"
  347. :key="item.companyId"
  348. :label="item.companyName"
  349. :value="item.companyId"
  350. />
  351. </el-select>
  352. </el-form-item>
  353. </el-form>
  354. <div slot="footer" class="dialog-footer">
  355. <el-button type="primary" @click="submitForm1">确 定</el-button>
  356. <el-button @click="cancel1">取 消</el-button>
  357. </div>
  358. </el-dialog>
  359. <!-- 添加或修改商品对话框 -->
  360. <el-dialog :title="title" v-if="open" :fullscreen="isFullscreen" :visible.sync="open" width="1000px" append-to-body :show-close="false">
  361. <template v-slot:title>
  362. <div style="display: flex; justify-content: space-between; align-items: center;">
  363. <span>{{ title }}</span>
  364. <div>
  365. <!-- 全屏按钮 -->
  366. <el-button type="text" @click="handleFullScreen" size="middle">
  367. <i class="el-icon-full-screen"></i>
  368. </el-button>
  369. <!--关闭按钮-->
  370. <el-button type="text" @click="open = false">
  371. <i class="el-icon-close"></i>
  372. </el-button>
  373. </div>
  374. </div>
  375. </template>
  376. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  377. <el-row >
  378. <el-col :span="12">
  379. <el-form-item label="商品名称" prop="productName">
  380. <el-input v-model="form.productName" placeholder="请输入商品名称" />
  381. </el-form-item>
  382. </el-col>
  383. <el-col :span="12">
  384. <el-form-item label="商品分类" prop="cateId">
  385. <treeselect v-model="form.cateId" :options="categoryOptions" :normalizer="normalizer" placeholder="请选择上级分类" />
  386. </el-form-item>
  387. </el-col>
  388. </el-row>
  389. <el-row>
  390. <el-col :span="12">
  391. <el-form-item label="关键字" prop="keyword">
  392. <el-input v-model="form.keyword" placeholder="请输入关键字" />
  393. </el-form-item>
  394. </el-col>
  395. <el-col :span="12">
  396. <el-form-item label="单位名" prop="unitName">
  397. <el-input v-model="form.unitName" placeholder="请输入单位名" />
  398. </el-form-item>
  399. </el-col>
  400. <el-col :span="12">
  401. <el-form-item label="品牌" prop="brand">
  402. <el-input v-model="form.brand" placeholder="请输入品牌" />
  403. </el-form-item>
  404. </el-col>
  405. <el-col :span="12">
  406. <el-form-item label="食品生产许可证编码" prop="unitName">
  407. <el-input v-model="form.foodProductionLicenseCode" placeholder="请输入食品生产许可证编码" />
  408. </el-form-item>
  409. </el-col>
  410. </el-row>
  411. <el-row :gutter="10">
  412. <el-col :span="12">
  413. <el-form-item label="是否药品" prop="isDrug">
  414. <el-radio-group v-model="form.isDrug">
  415. <el-radio
  416. v-for="item in isDrugOptions"
  417. :key="item.dictValue"
  418. :label="item.dictValue"
  419. >{{ item.dictLabel }}</el-radio>
  420. </el-radio-group>
  421. </el-form-item>
  422. </el-col>
  423. </el-row>
  424. <div v-if="form.isDrug === '1' ">
  425. <el-form-item label="药品展示图" prop="drugImage">
  426. <Material v-model="drugImageArr" type="image" :num="1" :width="150" :height="150" />
  427. </el-form-item>
  428. <div v-if="this.isMedicalMall">
  429. <el-row>
  430. <el-col :span="12">
  431. <el-form-item label="药品注册证书编号" prop="drugRegCertNo">
  432. <el-input v-model="form.drugRegCertNo" placeholder="请输入药品注册证书编号" />
  433. </el-form-item>
  434. </el-col>
  435. <el-col :span="12">
  436. <el-form-item label="通用名称" prop="commonName">
  437. <el-input v-model="form.commonName" placeholder="请输入通用名称" />
  438. </el-form-item>
  439. </el-col>
  440. </el-row>
  441. <el-row>
  442. <el-col :span="12">
  443. <el-form-item label="剂型" prop="dosageForm">
  444. <el-input v-model="form.dosageForm" placeholder="请输入剂型" />
  445. </el-form-item>
  446. </el-col>
  447. <el-col :span="12">
  448. <el-form-item label="单价" prop="unitPrice">
  449. <el-input v-model="form.unitPrice" placeholder="请输入单价" type="number" />
  450. </el-form-item>
  451. </el-col>
  452. </el-row>
  453. <el-row>
  454. <el-col :span="12">
  455. <el-form-item label="批号" prop="batchNumber">
  456. <el-input v-model="form.batchNumber" placeholder="请输入批号" />
  457. </el-form-item>
  458. </el-col>
  459. <el-col :span="12">
  460. <el-form-item label="规格" prop="prescribeSpec">
  461. <el-input v-model="form.prescribeSpec" placeholder="请输入规格" />
  462. </el-form-item>
  463. </el-col>
  464. </el-row>
  465. <el-row>
  466. <el-col :span="12">
  467. <el-form-item label="上市许可持有人" prop="mah">
  468. <el-input v-model="form.mah" placeholder="请输入上市许可持有人" />
  469. </el-form-item>
  470. </el-col>
  471. <el-col :span="12">
  472. <el-form-item label="持有人地址" prop="mahAddress">
  473. <el-input v-model="form.mahAddress" placeholder="请输入上市许可持有人地址" />
  474. </el-form-item>
  475. </el-col>
  476. </el-row>
  477. <el-row>
  478. <el-col :span="12">
  479. <el-form-item label="生产企业" prop="manufacturer">
  480. <el-input v-model="form.manufacturer" placeholder="请输入生产企业" />
  481. </el-form-item>
  482. </el-col>
  483. <el-col :span="12">
  484. <el-form-item label="企业地址" prop="manufacturerAddress">
  485. <el-input v-model="form.manufacturerAddress" placeholder="请输入生产企业地址" />
  486. </el-form-item>
  487. </el-col>
  488. </el-row>
  489. <el-form-item label="功能主治" prop="indications">
  490. <el-input v-model="form.indications" type="textarea" placeholder="请输入功能主治" />
  491. </el-form-item>
  492. <el-form-item label="用法用量" prop="dosage">
  493. <el-input v-model="form.dosage" type="textarea" placeholder="请输入用法用量" />
  494. </el-form-item>
  495. <el-form-item label="不良反应" prop="adverseReactions">
  496. <el-input v-model="form.adverseReactions" type="textarea" placeholder="请输入不良反应" />
  497. </el-form-item>
  498. <el-form-item label="禁忌" prop="contraindications">
  499. <el-input v-model="form.contraindications" type="textarea" placeholder="请输入禁忌" />
  500. </el-form-item>
  501. <el-form-item label="注意事项" prop="precautions">
  502. <el-input v-model="form.precautions" type="textarea" placeholder="请输入注意事项" />
  503. </el-form-item>
  504. </div>
  505. </div>
  506. <el-row>
  507. <el-col :span="24">
  508. <el-form-item label="商品简介" prop="productInfo">
  509. <el-input v-model="form.productInfo" type="textarea" :rows="2" placeholder="请输入商品简介" />
  510. </el-form-item>
  511. </el-col>
  512. </el-row>
  513. <el-form-item label="商品图片" prop="image">
  514. <Material v-model="imageArr" type="image" :num="1" :width="150" :height="150" />
  515. </el-form-item>
  516. <!-- <el-form-item label="商品视频" prop="video">
  517. <div>
  518. <el-upload
  519. ref="upload"
  520. class="upload-demo"
  521. :action="uploadUrl"
  522. :on-success="handleSuccess"
  523. :before-upload="beforeUpload"
  524. :limit="1"
  525. :accept="videoAccept"
  526. >
  527. <el-button size="small" type="primary">点击上传视频</el-button>
  528. </el-upload>
  529. <video v-if="form.video" :src="form.video" controls style="max-width: 300px; max-height: 300px; margin-top: 10px"></video>
  530. </div>
  531. </el-form-item>-->
  532. <el-form-item label="轮播图" prop="sliderImage">
  533. <Material v-model="photoArr" type="image" :num="10" :width="150" :height="150" />
  534. </el-form-item>
  535. <el-row>
  536. <el-col :span="24">
  537. <el-form-item label="商品规格:" props="specType">
  538. <el-radio-group v-model="form.specType" >
  539. <el-radio :label="0" class="radio">单规格</el-radio>
  540. <el-radio :label="1">多规格</el-radio>
  541. </el-radio-group>
  542. </el-form-item>
  543. </el-col>
  544. <!-- 多规格添加-->
  545. <el-col :span="24" v-if="form.specType === 1" class="noForm" >
  546. <el-col :span="24">
  547. <el-form-item label="选择规格:" prop="">
  548. <div class="acea-row row-middle">
  549. <el-select v-model="form.selectRule" style="width: 23%;">
  550. <el-option v-for="(item, index) in ruleList" :value="item.ruleName" :key="index">{{ item.ruleName }}</el-option>
  551. </el-select>
  552. <el-button style="margin-left:10px;" type="primary" class="mr20" @click="confirm">确认</el-button>
  553. </div>
  554. </el-form-item>
  555. </el-col>
  556. <el-col :span="24">
  557. <el-form-item v-if="attrs!=null&&attrs.length!==0">
  558. <div v-for="(item, index) in attrs" :key="index">
  559. <div class="acea-row row-middle"><span class="mr5">{{item.value}}</span>
  560. <i class="el-icon-circle-close" @click="handleRemoveRole(index)"></i>
  561. </div>
  562. <div class="rulesBox">
  563. <el-tag type="dot" closable color="primary" v-for="(j, indexn) in item.detail" :key="indexn" :name="j" class="mr20" @close="handleRemove2(item.detail,indexn)">{{j}}</el-tag>
  564. <el-input placeholder="请输入属性名称" v-model="item.detail.attrsVal"
  565. style="width: 200px">
  566. <el-button slot="append" type="primary" @click="createAttr(item.detail.attrsVal,index)">添加</el-button>
  567. </el-input>
  568. </div>
  569. </div>
  570. </el-form-item>
  571. </el-col>
  572. <el-col :span="24" v-if="createBnt">
  573. <el-form-item>
  574. <el-button type="primary" size="small" icon="md-add" @click="addBtn" class="mr15">添加新规格</el-button>
  575. <el-button type="success" size="small" @click="generate">立即生成</el-button>
  576. </el-form-item>
  577. </el-col>
  578. <el-col :span="24" v-if="showIput">
  579. <el-col :xl="6" :lg="9" :md="10" :sm="24" :xs="24" >
  580. <el-form-item label="规格:">
  581. <el-input placeholder="请输入规格" v-model="formDynamic.attrsName" />
  582. </el-form-item>
  583. </el-col>
  584. <el-col :xl="6" :lg="9" :md="10" :sm="24" :xs="24">
  585. <el-form-item label="规格值:">
  586. <el-input v-model="formDynamic.attrsVal" placeholder="请输入规格值" />
  587. </el-form-item>
  588. </el-col>
  589. <el-col :xl="6" :lg="5" :md="10" :sm="24" :xs="24" >
  590. <el-button type="primary" @click="createAttrName">确定</el-button>
  591. <el-button type="danger" @click="closeAttrName" >取消</el-button>
  592. </el-col>
  593. </el-col>
  594. <!-- 多规格设置-->
  595. <el-col :xl="24" :lg="24" :md="24" :sm="24" :xs="24" v-if="manyFormValidate!=null&&manyFormValidate.length">
  596. <!-- 多规格表格-->
  597. <el-col :span="24">
  598. <el-form-item label="商品属性:" class="labeltop">
  599. <el-table :data="manyFormValidate" size="small" style="width: 90%;" border>
  600. <el-table-column type="myindex" v-for="(item,index) in form.header" :key="index" :width="item.minWidth" :label="item.title" :property="item.slot" align="center">
  601. <template slot-scope="scope">
  602. <div v-if="scope.column.property == 'image'" align="center">
  603. <single-img v-model="scope.row[scope.column.property]" type="image" :num="1" :width="60" :height="60" />
  604. </div>
  605. <div v-else-if="scope.column.property.indexOf('value') != -1" align="center">
  606. {{ scope.row[scope.column.property] }}
  607. </div>
  608. <div v-else-if="scope.column.property == 'action'" align="center" >
  609. <a @click="delAttrTable(scope.$index)" align="center">删除</a>
  610. </div>
  611. <div v-else align="center">
  612. <el-input v-model="scope.row[scope.column.property]" align="center" />
  613. </div>
  614. </template>
  615. </el-table-column>
  616. </el-table>
  617. </el-form-item>
  618. </el-col>
  619. </el-col>
  620. </el-col>
  621. <!-- 单规格表格-->
  622. <el-col :xl="23" :lg="24" :md="24" :sm="24" :xs="24" v-if="form.specType === 0" style="">
  623. <el-form-item >
  624. <el-table :data="oneFormValidate" size="small" border>
  625. <el-table-column prop="image" label="图片" align="center">
  626. <template slot-scope="scope">
  627. <single-img v-model="scope.row.image" type="image" :num="1" :width="60" :height="60" />
  628. </template>
  629. </el-table-column>
  630. <el-table-column prop="price" label="售价" align="center">
  631. <template slot-scope="scope">
  632. <el-input type="text" v-model="scope.row.price"/>
  633. </template>
  634. </el-table-column>
  635. <el-table-column prop="agentPrice" label="代理价" align="center">
  636. <template slot-scope="scope">
  637. <el-input type="text" v-model="scope.row.agentPrice"/>
  638. </template>
  639. </el-table-column>
  640. <el-table-column prop="cost" label="成本价" align="center">
  641. <template slot-scope="scope">
  642. <el-input type="text" v-model="scope.row.cost"/>
  643. </template>
  644. </el-table-column>
  645. <el-table-column prop="otPrice" label="原价" align="center">
  646. <template slot-scope="scope">
  647. <el-input type="text" v-model="scope.row.otPrice"/>
  648. </template>
  649. </el-table-column>
  650. <el-table-column prop="stock" label="库存" align="center">
  651. <template slot-scope="scope">
  652. <el-input type="text" v-model="scope.row.stock" maxlength="7"/>
  653. </template>
  654. </el-table-column>
  655. <el-table-column prop="barCode" label="商品编号" width="130px" align="center">
  656. <template slot-scope="scope">
  657. <el-input type="text" v-model="scope.row.barCode"/>
  658. </template>
  659. </el-table-column>
  660. <el-table-column prop="barCode" label="组合编号" width="130px" align="center">
  661. <template slot-scope="scope">
  662. <el-input type="text" v-model="scope.row.groupBarCode"/>
  663. </template>
  664. </el-table-column>
  665. <el-table-column prop="weight" label="重量(KG)" align="center">
  666. <template slot-scope="scope">
  667. <el-input type="text" v-model="scope.row.weight"/>
  668. </template>
  669. </el-table-column>
  670. <el-table-column prop="volume" label="体积(m³)" align="center">
  671. <template slot-scope="scope">
  672. <el-input type="text" v-model="scope.row.volume"/>
  673. </template>
  674. </el-table-column>
  675. <el-table-column prop="volume" label="所需积分" align="center">
  676. <template slot-scope="scope">
  677. <el-input type="text" v-model="scope.row.integral"/>
  678. </template>
  679. </el-table-column>
  680. <el-table-column prop="volume" label="一级返佣" align="center">
  681. <template slot-scope="scope">
  682. <el-input type="text" v-model="scope.row.brokerage"/>
  683. </template>
  684. </el-table-column>
  685. <el-table-column prop="volume" label="二级返佣" align="center">
  686. <template slot-scope="scope">
  687. <el-input type="text" v-model="scope.row.brokerageTwo"/>
  688. </template>
  689. </el-table-column>
  690. <el-table-column prop="volume" label="三级返佣" align="center">
  691. <template slot-scope="scope">
  692. <el-input type="text" v-model="scope.row.brokerageThree"/>
  693. </template>
  694. </el-table-column>
  695. </el-table>
  696. </el-form-item>
  697. </el-col>
  698. <el-col :span="24">
  699. <el-form-item label="运费模板:" prop="tempId">
  700. <div class="acea-row">
  701. <el-select v-model="form.tempId" class="mr20">
  702. <el-option v-for="(item,index) in templateList" :value="item.id" :key="index" :label="item.name">
  703. </el-option>
  704. </el-select>
  705. </div>
  706. </el-form-item>
  707. </el-col>
  708. </el-row>
  709. <el-form-item label="商品详情" prop="description">
  710. <editor ref="myeditor" @on-text-change="updateText" />
  711. </el-form-item>
  712. <el-row>
  713. <el-col :span="8">
  714. <el-form-item label="商品状态" prop="isShow">
  715. <el-radio-group v-model="form.isShow">
  716. <el-radio :label="item.dictValue" v-for="item in isShowOptions" >{{item.dictLabel}}</el-radio>
  717. </el-radio-group>
  718. </el-form-item>
  719. </el-col>
  720. <el-col :span="8">
  721. <el-form-item label="是否热卖" prop="isHot">
  722. <el-radio-group v-model="form.isHot">
  723. <el-radio :label="item.dictValue" v-for="item in isHotOptions" >{{item.dictLabel}}</el-radio>
  724. </el-radio-group>
  725. </el-form-item>
  726. </el-col>
  727. <el-col :span="8">
  728. <el-form-item label="猜你喜欢" prop="isGood">
  729. <el-radio-group v-model="form.isGood">
  730. <el-radio :label="item.dictValue" v-for="item in isGoodOptions" >{{item.dictLabel}}</el-radio>
  731. </el-radio-group>
  732. </el-form-item>
  733. </el-col>
  734. </el-row>
  735. <el-row>
  736. <el-col :span="8">
  737. <el-form-item label="精品推荐" prop="isBest">
  738. <el-radio-group v-model="form.isBest">
  739. <el-radio :label="item.dictValue" v-for="item in isBestOptions" >{{item.dictLabel}}</el-radio>
  740. </el-radio-group>
  741. </el-form-item>
  742. </el-col>
  743. <el-col :span="8">
  744. <el-form-item label="新品首发" prop="isNew">
  745. <el-radio-group v-model="form.isNew">
  746. <el-radio :label="item.dictValue" v-for="item in isNewOptions" >{{item.dictLabel}}</el-radio>
  747. </el-radio-group>
  748. </el-form-item>
  749. </el-col>
  750. <el-col :span="8">
  751. <el-form-item label="返还积分">
  752. <el-input-number v-model="form.giveIntegral" :min="0" placeholder="请输入积分" />
  753. </el-form-item>
  754. </el-col>
  755. </el-row>
  756. <el-row>
  757. <el-col :span="8">
  758. <el-form-item label="商城展示" prop="isDisplay">
  759. <el-radio-group v-model="form.isDisplay">
  760. <el-radio :label="item.dictValue" v-for="item in isDisplayOptions" >{{item.dictLabel}}</el-radio>
  761. </el-radio-group>
  762. </el-form-item>
  763. </el-col>
  764. <el-col :span="8">
  765. <el-form-item label="排序" prop="sort">
  766. <el-input-number :min="0" v-model="form.sort" placeholder="请输入排序" />
  767. </el-form-item>
  768. </el-col>
  769. <el-col :span="8">
  770. <el-form-item label="销量" prop="sales">
  771. <el-input-number :min="0" v-model="form.sales" placeholder="请输入销量" />
  772. </el-form-item>
  773. </el-col>
  774. <el-col :span="8">
  775. <el-form-item label="限购数量" prop="purchaseLimit">
  776. <el-input-number
  777. :min="0"
  778. v-model="form.purchaseLimit"
  779. placeholder="请输入限购数量"
  780. :controls="true"
  781. @input="handlePurchaseLimitInput"
  782. />
  783. </el-form-item>
  784. </el-col>
  785. </el-row>
  786. <el-form-item label="推广分类" prop="tuiCateId">
  787. <el-select style="width: 240px" v-model="form.tuiCateId" placeholder="请选择推广分类" clearable size="small" >
  788. <el-option
  789. v-for="item in productTuiCateOptions"
  790. :key="item.dictValue"
  791. :label="item.dictLabel"
  792. :value="item.dictValue"
  793. />
  794. </el-select>
  795. </el-form-item>
  796. <el-form-item label="商品类型" prop="productType">
  797. <el-select style="width: 240px" v-model="form.productType" placeholder="请选择商品类型" clearable size="small">
  798. <el-option
  799. v-for="item in productTypeOptions"
  800. :key="item.dictValue"
  801. :label="item.dictLabel"
  802. :value="item.dictValue"
  803. />
  804. </el-select>
  805. </el-form-item>
  806. <el-form-item label="所属公司">
  807. <el-select style="width: 240px" v-model="form.companyIds" multiple placeholder="请选择企业" clearable size="small" >
  808. <el-option
  809. v-for="item in companyOptions"
  810. :key="item.companyId"
  811. :label="item.companyName"
  812. :value="item.companyId"
  813. />
  814. </el-select>
  815. </el-form-item>
  816. <el-form-item label="所属店铺" prop="storeId" v-if="this.isStores">
  817. <el-select style="width: 240px" v-model="form.storeId" placeholder="请选择店铺" clearable size="small" >
  818. <el-option
  819. v-for="item in storeOptions"
  820. :key="item.storeId"
  821. :label="item.storeName"
  822. :value="item.storeId"
  823. />
  824. </el-select>
  825. </el-form-item>
  826. <el-form-item label="所属小程序" prop="appIds">
  827. <el-select style="width: 240px" v-model="appIds" placeholder="请选择所属小程序" clearable size="small" multiple>
  828. <el-option
  829. v-for="dict in appMallOptions"
  830. :key="dict.appid"
  831. :label="dict.name + '(' + dict.appid + ')'"
  832. :value="dict.appid"
  833. />
  834. </el-select>
  835. </el-form-item>
  836. <el-form-item label="退货地址" prop="returnAddress">
  837. <el-input v-model="form.returnAddress" type="textarea" :rows="1" placeholder="请输入退货地址" />
  838. </el-form-item>
  839. <el-form-item label="国药准字" v-if="form.productType==2" prop="prescribeCode">
  840. <el-input v-model="form.prescribeCode" placeholder="请输入国药准字" />
  841. </el-form-item>
  842. <el-form-item label="规格" v-if="form.productType==2" prop="prescribeSpec">
  843. <el-input v-model="form.prescribeSpec" placeholder="请输入规格" />
  844. </el-form-item>
  845. <el-form-item label="生产厂家" v-if="form.productType==2" prop="prescribeFactory">
  846. <el-input v-model="form.prescribeFactory" placeholder="请输入生产厂家" />
  847. </el-form-item>
  848. <el-form-item label="处方名" v-if="form.productType==2" prop="prescribeName">
  849. <el-input v-model="form.prescribeName" placeholder="请输入处方名" />
  850. </el-form-item>
  851. </el-form>
  852. <div slot="footer" class="dialog-footer">
  853. <el-button type="primary" @click="submitForm">确 定</el-button>
  854. <el-button @click="cancel">取 消</el-button>
  855. </div>
  856. </el-dialog>
  857. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  858. <el-upload
  859. ref="upload"
  860. :limit="1"
  861. accept=".xlsx, .xls"
  862. :headers="upload.headers"
  863. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  864. :disabled="upload.isUploading"
  865. :on-progress="handleFileUploadProgress"
  866. :on-success="handleFileSuccess"
  867. :auto-upload="false"
  868. drag
  869. >
  870. <i class="el-icon-upload"></i>
  871. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  872. <div class="el-upload__tip text-center" slot="tip">
  873. <div class="el-upload__tip" slot="tip">
  874. <!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的数据 -->
  875. </div>
  876. <span>仅允许导入xls、xlsx格式文件。</span>
  877. <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
  878. </div>
  879. </el-upload>
  880. <div slot="footer" class="dialog-footer">
  881. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  882. <el-button @click="upload.open = false">取 消</el-button>
  883. </div>
  884. </el-dialog>
  885. </div>
  886. </template>
  887. <script>
  888. import {
  889. genFormatAttr,
  890. listStoreProduct,
  891. getStoreProduct,
  892. delStoreProduct,
  893. addOrEdit,
  894. exportStoreProduct,
  895. importTemplate,
  896. batchModify,bulkCopy
  897. } from "@/api/hisStore/storeProduct";
  898. import { getAllStoreProductCategory } from "@/api/hisStore/storeProductCategory";
  899. import { getAllStoreProductRule } from "@/api/hisStore/storeProductRule";
  900. import { getAllShippingTemplates } from "@/api/hisStore/shippingTemplates";
  901. import { getToken } from "@/utils/auth";
  902. import Treeselect from "@riophae/vue-treeselect";
  903. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  904. import Editor from '@/components/Editor/wang';
  905. import Material from '@/components/Material'
  906. import singleImg from '@/components/Material/single'
  907. import { getCompanyList } from "@/api/company/company";
  908. import { listStore } from '@/api/hisStore/store'
  909. import {list as getAppMallOptions} from "@/api/course/coursePlaySourceConfig";
  910. export default {
  911. name: "HisStoreProduct",
  912. components: {
  913. Treeselect,
  914. Editor,
  915. Material,
  916. singleImg,
  917. },
  918. watch: {
  919. imageArr: function(val) {
  920. this.form.image = val.join(',')
  921. },
  922. photoArr: function(val) {
  923. this.form.sliderImage = val.join(',')
  924. },
  925. drugImageArr: function(val) {
  926. this.form.drugImage = val.join(',');
  927. }
  928. },
  929. data() {
  930. return {
  931. isMedicalMall: this.$store.state.user.medicalMallConfig.medicalMall,
  932. // isStores: this.$store.state.user.medicalMallConfig.stores,
  933. isStores: true,
  934. companyId: null,
  935. storeId: null,
  936. isAudit: null,
  937. uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
  938. //videoAccept:"video/*",
  939. upload: {
  940. // 是否显示弹出层
  941. open: false,
  942. // 弹出层标题
  943. title: "",
  944. // 是否禁用上传
  945. isUploading: false,
  946. // 是否更新已经存在的用户数据
  947. updateSupport: 0,
  948. // 设置上传的请求头部
  949. headers: { Authorization: "Bearer " + getToken() },
  950. // 上传的地址
  951. url: process.env.VUE_APP_BASE_API + "/store/store/storeProduct/importData"
  952. },
  953. // 添加药品相关字段
  954. isDrugOptions: [
  955. { dictValue: "0", dictLabel: "否" },
  956. { dictValue: "1", dictLabel: "是" }
  957. ],
  958. // 药品展示图
  959. drugImageArr: [],
  960. productTuiCateOptions:[],
  961. showIput: false,
  962. createBnt:true,
  963. // 规格数据
  964. formDynamic: {
  965. attrsName: '',
  966. attrsVal: ''
  967. },
  968. open1: false,
  969. form1: {},
  970. isBtn: false,
  971. columns: [],
  972. attrs:[],
  973. templateList:[],
  974. ruleList:[],
  975. // 多规格表格data
  976. manyFormValidate: [],
  977. // 单规格表格data
  978. oneFormValidate: [
  979. {
  980. image: '',
  981. price: 0,
  982. cost: 0,
  983. agentPrice: 0,
  984. otPrice: 0,
  985. stock: 0,
  986. barCode: '',
  987. weight: 0,
  988. volume: 0,
  989. integral: 0
  990. }
  991. ],
  992. photoArr:[],
  993. imageArr:[],
  994. activeName:"1",
  995. productTypeOptions:[],
  996. isDisplayOptions:[],
  997. isGoodOptions:[],
  998. isNewOptions:[],
  999. isBestOptions:[],
  1000. isHotOptions:[],
  1001. isShowOptions:[],
  1002. categoryOptions:[],
  1003. // 企业列表
  1004. companyOptions:[],
  1005. storeOptions:[],
  1006. // 遮罩层
  1007. loading: true,
  1008. // 选中数组
  1009. ids: [],
  1010. // 非单个禁用
  1011. single: false,
  1012. // 非多个禁用
  1013. multiple: true,
  1014. // 显示搜索条件
  1015. showSearch: true,
  1016. isFullscreen: false,
  1017. // 总条数
  1018. total: 0,
  1019. // 商品表格数据
  1020. storeProductList: [],
  1021. // 弹出层标题
  1022. title: "",
  1023. // 是否显示弹出层
  1024. open: false,
  1025. // 小程序列表
  1026. appMallOptions:[],
  1027. appIds:[], // 选择的小程序
  1028. // 查询参数
  1029. queryParams: {
  1030. pageNum: 1,
  1031. pageSize: 10,
  1032. productName: null,
  1033. productType: null,
  1034. isShow: "1",
  1035. barCode:null,
  1036. companyIds: null,
  1037. storeIds: null,
  1038. drugRegCertNo: null,
  1039. commonName: null,
  1040. dosageForm: null,
  1041. unitPrice: null,
  1042. batchNumber: null,
  1043. mah: null,
  1044. mahAddress: null,
  1045. manufacturer: null,
  1046. manufacturerAddress: null,
  1047. indications: null,
  1048. dosage: null,
  1049. adverseReactions: null,
  1050. contraindications: null,
  1051. precautions: null
  1052. },
  1053. // 表单参数
  1054. form: {},
  1055. storeForm: {isAudit:1,status:1},
  1056. // 表单校验
  1057. rules: {
  1058. image: [
  1059. { required: true, message: "商品图片不能为空", trigger: "blur" }
  1060. ],
  1061. sliderImage: [
  1062. { required: true, message: "轮播图不能为空", trigger: "blur" }
  1063. ],
  1064. productName: [
  1065. { required: true, message: "商品名称不能为空", trigger: "blur" }
  1066. ],
  1067. // productInfo: [
  1068. // { required: true, message: "商品简介不能为空", trigger: "blur" }
  1069. // ],
  1070. // unitName: [
  1071. // { required: true, message: "单位名不能为空", trigger: "blur" }
  1072. // ],
  1073. // keyword: [
  1074. // { required: true, message: "关键字不能为空", trigger: "blur" }
  1075. // ],
  1076. cateId: [
  1077. { required: true, message: "分类id不能为空", trigger: "blur" }
  1078. ],
  1079. price: [
  1080. { required: true, message: "商品价格不能为空", trigger: "blur" }
  1081. ],
  1082. prescribeCode: [
  1083. { required: true, message: "国药准字不能为空", trigger: "blur" }
  1084. ],
  1085. prescribeSpec: [
  1086. { required: true, message: "规格不能为空", trigger: "blur" }
  1087. ],
  1088. prescribeFactory: [
  1089. { required: true, message: "生产厂家不能为空", trigger: "blur" }
  1090. ],
  1091. prescribeName: [
  1092. { required: true, message: "处方药不能为空", trigger: "blur" }
  1093. ],
  1094. companyIds: [
  1095. { required: true, message: "销售公司不能为空", trigger: "blur" }
  1096. ],
  1097. // 药品相关字段校验(仅在是药品时必填)
  1098. drugImage: [
  1099. { required: true, message: "药品展示图不能为空", trigger: "blur" }
  1100. ],
  1101. drugRegCertNo: [
  1102. { required: true, message: "药品注册证书编号不能为空", trigger: "blur" }
  1103. ],
  1104. commonName: [
  1105. { required: true, message: "通用名称不能为空", trigger: "blur" }
  1106. ],
  1107. dosageForm: [
  1108. { required: true, message: "剂型不能为空", trigger: "blur" }
  1109. ],
  1110. unitPrice: [
  1111. { required: true, message: "单价不能为空", trigger: "blur" }
  1112. ],
  1113. batchNumber: [
  1114. { required: true, message: "批号不能为空", trigger: "blur" }
  1115. ],
  1116. mah: [
  1117. { required: true, message: "上市许可持有人不能为空", trigger: "blur" }
  1118. ],
  1119. mahAddress: [
  1120. { required: true, message: "上市许可持有人地址不能为空", trigger: "blur" }
  1121. ],
  1122. manufacturer: [
  1123. { required: true, message: "生产企业不能为空", trigger: "blur" }
  1124. ],
  1125. manufacturerAddress: [
  1126. { required: true, message: "生产企业地址不能为空", trigger: "blur" }
  1127. ],
  1128. indications: [
  1129. { required: true, message: "功能主治不能为空", trigger: "blur" }
  1130. ],
  1131. dosage: [
  1132. { required: true, message: "用法用量不能为空", trigger: "blur" }
  1133. ],
  1134. adverseReactions: [
  1135. { required: true, message: "不良反应不能为空", trigger: "blur" }
  1136. ],
  1137. contraindications: [
  1138. { required: true, message: "禁忌不能为空", trigger: "blur" }
  1139. ],
  1140. precautions: [
  1141. { required: true, message: "注意事项不能为空", trigger: "blur" }
  1142. ],
  1143. storeId :[
  1144. { required: true, message: "所属店铺不能为空", trigger: "blur"}
  1145. ],
  1146. }
  1147. };
  1148. },
  1149. created() {
  1150. this.getDicts("store_product_tui_cate").then((response) => {
  1151. this.productTuiCateOptions = response.data;
  1152. });
  1153. this.getDicts("store_product_enable").then((response) => {
  1154. this.isNewOptions = response.data;
  1155. this.isBestOptions = response.data;
  1156. this.isHotOptions = response.data;
  1157. this.isGoodOptions=response.data;
  1158. this.isDisplayOptions=response.data;
  1159. });
  1160. this.getDicts("store_product_type").then((response) => {
  1161. this.productTypeOptions = response.data;
  1162. if(!this.isMedicalMall &&
  1163. this.productTypeOptions.length === 4){
  1164. //删除后两项
  1165. this.productTypeOptions.splice(2,2);
  1166. }
  1167. });
  1168. this.getDicts("store_product_is_show").then((response) => {
  1169. this.isShowOptions = response.data;
  1170. });
  1171. getAllShippingTemplates().then(response => {
  1172. this.templateList =response.data;
  1173. });
  1174. getAllStoreProductRule().then(response => {
  1175. this.ruleList =response.data;
  1176. });
  1177. getCompanyList().then(response => {
  1178. this.companyOptions = response.data;
  1179. });
  1180. // 查询小程序
  1181. this.getAppMallOptions();
  1182. listStore(this.storeForm).then(response => {
  1183. this.storeOptions = response.rows;
  1184. });
  1185. this.getTreeselect();
  1186. this.getList();
  1187. },
  1188. methods: {
  1189. getAppMallOptions() {
  1190. getAppMallOptions({pageNum:1,pageSize:100}).then(response => {
  1191. this.appMallOptions = response.rows;
  1192. })
  1193. },
  1194. getStatusText(row) {
  1195. console.log()
  1196. if (row.isAudit == 0) {
  1197. return '待审核';
  1198. }
  1199. const option = this.isShowOptions.find(item => item.dictValue == row.isShow);
  1200. return option ? option.dictLabel : '未知状态';
  1201. },
  1202. getStatusType(row) {
  1203. console.log(row)
  1204. if (row.isAudit == 0) {
  1205. return 'warning';
  1206. }
  1207. // 根据你的业务逻辑返回不同的类型,如:success, danger, info等
  1208. return row.isShow == 1 ? 'success' : 'info';
  1209. },
  1210. cancel1(){
  1211. this.open1 = false;
  1212. },
  1213. submitForm1(){
  1214. let param = {}
  1215. param.productId = this.ids;
  1216. param.goodsStatus = this.form1.isShow;
  1217. param.goodsIsShow = this.form1.isDisplay;
  1218. param.companyIds = this.form1.companyId.join(',');
  1219. batchModify(param).then(res=>{
  1220. if(res.code === 200){
  1221. this.$message.success("批量修改成功");
  1222. this.getList();
  1223. }
  1224. }).finally(()=>{
  1225. this.open1 = false;
  1226. this.form1.isShow = null;
  1227. this.form1.isDisplay = null;
  1228. this.form1.companyId = null;
  1229. })
  1230. },
  1231. handleFullScreen(){
  1232. this.isFullscreen = !this.isFullscreen;
  1233. },
  1234. handleSuccess(response, file) {
  1235. // 上传成功后的回调函数
  1236. this.myloading.close();
  1237. //this.form.video = response.url;
  1238. this.$refs.upload.clearFiles();
  1239. },
  1240. beforeUpload(file) {
  1241. // 上传前的钩子函数,可以在这里对文件进行处理
  1242. // 返回 false 则取消上传
  1243. // 例如限制文件大小
  1244. const isLt2M = file.size / 1024 / 1024 < 200;
  1245. if (!isLt2M) {
  1246. this.$message.error('上传视频文件大小不能超过 200MB!');
  1247. return false;
  1248. }
  1249. this.myloading = this.$loading({
  1250. lock: true,
  1251. text: '上传中',
  1252. spinner: 'el-icon-loading',
  1253. background: 'rgba(0, 0, 0, 0.7)'
  1254. });
  1255. },
  1256. // 提交上传文件
  1257. submitFileForm() {
  1258. this.$refs.upload.submit();
  1259. },
  1260. // 文件上传中处理
  1261. handleFileUploadProgress(event, file, fileList) {
  1262. this.upload.isUploading = true;
  1263. },
  1264. // 文件上传成功处理
  1265. handleFileSuccess(response, file, fileList) {
  1266. this.upload.open = false;
  1267. this.upload.isUploading = false;
  1268. this.$refs.upload.clearFiles();
  1269. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  1270. this.getList();
  1271. },
  1272. handleImport() {
  1273. this.upload.title = "商品导入";
  1274. this.upload.open = true;
  1275. },
  1276. importTemplate() {
  1277. importTemplate().then(response => {
  1278. this.download(response.msg);
  1279. });
  1280. },
  1281. // 删除表格中的属性
  1282. delAttrTable (index) {
  1283. this.manyFormValidate.splice(index, 1);
  1284. },
  1285. addBtn () {
  1286. this.clearAttr();
  1287. this.createBnt = false;
  1288. this.showIput = true;
  1289. },
  1290. //生成SKU
  1291. generate () {
  1292. var prodoct = this.form.productId?this.form.productId:0;
  1293. genFormatAttr(prodoct, { attrs: this.attrs }).then(res => {
  1294. if(this.form.specType === 0){
  1295. this.oneFormValidate = res.value;
  1296. this.form.header = res.header;
  1297. let header = res.header;
  1298. header.pop();
  1299. this.oneFormValidate.map((item) => {
  1300. if(this.imageArr.length>0){
  1301. item.image = this.imageArr[0]
  1302. }
  1303. });
  1304. }else if(this.form.specType === 1) {
  1305. this.manyFormValidate = res.value;
  1306. let headerdel = {
  1307. title: '操作',
  1308. slot: 'action',
  1309. fixed: 'right',
  1310. width: 220
  1311. };
  1312. res.header.push(headerdel);
  1313. this.form.header = res.header;
  1314. let header = res.header;
  1315. header.pop();
  1316. // this.manyFormValidate.map((item) => {
  1317. // if(this.imageArr.length>0){
  1318. // item.image = this.imageArr[0]
  1319. // }
  1320. // });
  1321. }
  1322. }).catch(res => {
  1323. })
  1324. },
  1325. // 取消添加新规格
  1326. closeAttrName () {
  1327. this.showIput = false;
  1328. this.createBnt = true;
  1329. },
  1330. clearAttr () {
  1331. this.formDynamic.attrsName = '';
  1332. this.formDynamic.attrsVal = '';
  1333. },
  1334. // 处理限购数量输入
  1335. handlePurchaseLimitInput(value) {
  1336. // 只允许输入纯数字
  1337. if (value !== null && value !== undefined && value !== '') {
  1338. // 如果不是数字,设置为null
  1339. if (isNaN(value) || value < 0) {
  1340. this.$nextTick(() => {
  1341. this.form.purchaseLimit = null;
  1342. });
  1343. } else {
  1344. // 确保是整数
  1345. this.form.purchaseLimit = Math.floor(Number(value));
  1346. }
  1347. }
  1348. },
  1349. // 删除规格
  1350. handleRemoveRole (index) {
  1351. this.attrs.splice(index, 1);
  1352. this.manyFormValidate.splice(index, 1);
  1353. },
  1354. // 删除属性
  1355. handleRemove2 (item, index) {
  1356. item.splice(index, 1);
  1357. },
  1358. // 添加规则名称
  1359. createAttrName () {
  1360. if (this.formDynamic.attrsName && this.formDynamic.attrsVal) {
  1361. let data = {
  1362. value: this.formDynamic.attrsName,
  1363. detail: [
  1364. this.formDynamic.attrsVal
  1365. ]
  1366. };
  1367. this.attrs.push(data);
  1368. var hash = {};
  1369. this.attrs = this.attrs.reduce(function (item, next) {
  1370. hash[next.value] ? '' : hash[next.value] = true && item.push(next);
  1371. return item
  1372. }, [])
  1373. this.clearAttr();
  1374. this.showIput = false;
  1375. this.createBnt = true;
  1376. } else {
  1377. this.$message.warning('请添加完整的规格!');
  1378. }
  1379. },
  1380. // 添加属性
  1381. createAttr (num, idx) {
  1382. if (num) {
  1383. this.attrs[idx].detail.push(num);
  1384. var hash = {};
  1385. this.attrs[idx].detail = this.attrs[idx].detail.reduce(function (item, next) {
  1386. hash[next] ? '' : hash[next] = true && item.push(next);
  1387. return item
  1388. }, [])
  1389. } else {
  1390. this.$message.warning('请添加属性!');
  1391. }
  1392. },
  1393. confirm () {
  1394. let that = this;
  1395. that.createBnt = true;
  1396. if (that.form.selectRule==null||that.form.selectRule.trim().length <= 0) {
  1397. return this.$message({
  1398. message:'请选择属性',
  1399. type: 'error'
  1400. });
  1401. }
  1402. that.ruleList.forEach(function (item, index) {
  1403. if (item.ruleName === that.form.selectRule) {
  1404. that.attrs =JSON.parse( item.ruleValue);
  1405. }
  1406. });
  1407. },
  1408. updateText(text){
  1409. this.form.description=text
  1410. },
  1411. handleClick(tab, event) {
  1412. this.queryParams.isShow=tab.name;
  1413. this.getList();
  1414. },
  1415. /** 转换商品分类数据结构 */
  1416. normalizer(node) {
  1417. if (node.children && !node.children.length) {
  1418. delete node.children;
  1419. }
  1420. return {
  1421. id: node.cateId,
  1422. label: node.cateName,
  1423. children: node.children
  1424. };
  1425. },
  1426. getTreeselect() {
  1427. getAllStoreProductCategory().then(response => {
  1428. this.categoryOptions = [];
  1429. const data = this.handleTree(response.data, "cateId", "pid");
  1430. this.categoryOptions=data;
  1431. });
  1432. },
  1433. /** 查询商品列表 */
  1434. getList() {
  1435. this.loading = true;
  1436. listStoreProduct(this.queryParams).then(response => {
  1437. this.storeProductList = response.rows;
  1438. this.total = response.total;
  1439. this.loading = false;
  1440. });
  1441. },
  1442. // 取消按钮
  1443. cancel() {
  1444. this.open = false;
  1445. this.reset();
  1446. },
  1447. // 表单重置
  1448. reset() {
  1449. this.form = {
  1450. productId: null,
  1451. image: null,
  1452. video: null,
  1453. sliderImage: null,
  1454. productName: null,
  1455. productInfo: null,
  1456. keyword: null,
  1457. barCode: null,
  1458. cateId: null,
  1459. price: null,
  1460. vipPrice: null,
  1461. otPrice: null,
  1462. postage: null,
  1463. unitName: null,
  1464. sort: null,
  1465. sales: null,
  1466. stock: null,
  1467. isShow: "0",
  1468. isHot: "0",
  1469. isBenefit: "0",
  1470. isBest: "0",
  1471. isNew: "0",
  1472. description: null,
  1473. createTime: null,
  1474. updateTime: null,
  1475. isPostage: null,
  1476. foodProductionLicenseCode: null,
  1477. brand: null,
  1478. isDel: null,
  1479. giveIntegral: null,
  1480. cost: null,
  1481. isGood: "0",
  1482. browse: null,
  1483. codePath: null,
  1484. tempId: "",
  1485. specType: 0,
  1486. isIntegral: null,
  1487. integral: null,
  1488. productType: "1",
  1489. prescribeCode: null,
  1490. prescribeSpec: null,
  1491. prescribeFactory: null,
  1492. prescribeName: null,
  1493. isDisplay:"1",
  1494. companyIds:[],
  1495. returnAddress: "", // 退货地址
  1496. isDrug: "1", // 是否药品
  1497. drugImage: null, // 药品展示图
  1498. drugRegCertNo: null, // 药品注册证书编号
  1499. commonName: null, // 通用名称
  1500. dosageForm: null, // 剂型
  1501. unitPrice: null, // 单价
  1502. batchNumber: null, // 批号
  1503. mah: null, // 上市许可持有人
  1504. mahAddress: null, // 上市许可持有人地址
  1505. manufacturer: null, // 生产企业
  1506. manufacturerAddress: null, // 生产企业地址
  1507. indications: null, // 功能主治
  1508. dosage: null, // 用法用量
  1509. adverseReactions: null, // 不良反应
  1510. contraindications: null, // 禁忌
  1511. precautions: null, // 注意事项
  1512. purchaseLimit: null // 限购数量
  1513. };
  1514. // 重置药品展示图
  1515. this.drugImageArr = [];
  1516. this.resetForm("form");
  1517. this.oneFormValidate = [
  1518. {
  1519. image: '',
  1520. price: 0,
  1521. agentPrice: 0,
  1522. cost: 0,
  1523. otPrice: 0,
  1524. stock: 0,
  1525. barCode: '',
  1526. weight: 0,
  1527. volume: 0,
  1528. integral: 0,
  1529. brokerage:0,
  1530. brokerageTwo:0
  1531. }
  1532. ]
  1533. this.attrs=[];
  1534. this.photoArr=[];
  1535. this.imageArr=[];
  1536. },
  1537. /** 搜索按钮操作 */
  1538. handleQuery() {
  1539. this.queryParams.pageNum = 1;
  1540. this.queryParams.companyIds = this.companyId +''
  1541. this.getList();
  1542. },
  1543. /** 重置按钮操作 */
  1544. resetQuery() {
  1545. this.resetForm("queryForm");
  1546. this.handleQuery();
  1547. },
  1548. // 多选框选中数据
  1549. handleSelectionChange(selection) {
  1550. this.ids = selection.map(item => item.productId)
  1551. this.single = selection.length!==1
  1552. this.multiple = !selection.length
  1553. },
  1554. /** 新增按钮操作 */
  1555. handleAdd() {
  1556. this.reset();
  1557. this.open = true;
  1558. this.title = "添加商品";
  1559. setTimeout(() => {
  1560. this.$refs.myeditor.setText("");
  1561. }, 500);
  1562. },
  1563. /** 修改按钮操作 */
  1564. handleUpdate(row) {
  1565. if(this.ids.length > 1){
  1566. this.title = "批量修改商品";
  1567. this.open1 = true;
  1568. return;
  1569. }
  1570. var that=this;
  1571. this.reset();
  1572. const productId = row.productId || this.ids
  1573. getStoreProduct(productId).then(response => {
  1574. this.form = response.data;
  1575. this.form.isShow = response.data.isShow.toString();
  1576. this.form.isHot = response.data.isHot.toString();
  1577. this.form.isGood = response.data.isGood.toString();
  1578. this.form.isBest = response.data.isBest.toString();
  1579. this.form.isNew = response.data.isNew.toString();
  1580. this.form.productType = response.data.productType.toString();
  1581. this.form.isDisplay = response.data.isDisplay.toString();
  1582. if(this.form.tuiCateId!=null){
  1583. this.form.tuiCateId = response.data.tuiCateId.toString();
  1584. }
  1585. // this.form.isDrug = response.data.isDrug ? response.data.isDrug.toString() : "1";
  1586. this.form.isDrug = response.data.isDrug === 0 ? "0" : (response.data.isDrug ? response.data.isDrug.toString() : "1");
  1587. if (this.form.drugImage != null) {
  1588. this.drugImageArr = this.form.drugImage.split(",");
  1589. }
  1590. //组装attrs数据
  1591. if(response.attrs!=null){
  1592. this.attrs=[];
  1593. response.attrs.forEach(function (item, index) {
  1594. var data={value:item.attrName,detail:item.attrValues.split(',')}
  1595. that.attrs.push(data);
  1596. });
  1597. }
  1598. // 组装companyIds
  1599. if (response.data.companyIds != null && response.data.companyIds != undefined && response.data.companyIds.length > 0) {
  1600. this.form.companyIds = response.data.companyIds.split(',').map(Number);
  1601. }
  1602. this.appIds = this.form.appIds ? this.form.appIds.split(',') : [];
  1603. setTimeout(() => {
  1604. that.generate();
  1605. }, 200);
  1606. if(this.form.specType === 0){
  1607. that.manyFormValidate = [];
  1608. }else {
  1609. that.createBnt = true;
  1610. that.oneFormValidate = [
  1611. {
  1612. image: '',
  1613. price: 0,
  1614. agentPrice: 0,
  1615. cost: 0,
  1616. otPrice: 0,
  1617. stock: 0,
  1618. barCode: '',
  1619. weight: 0,
  1620. volume: 0,
  1621. integral: 0,
  1622. brokerage:0,
  1623. brokerageTwo:0
  1624. }
  1625. ]
  1626. }
  1627. setTimeout(() => {
  1628. if(this.form.description==null){
  1629. this.$refs.myeditor.setText("");
  1630. }
  1631. else{
  1632. this.$refs.myeditor.setText(this.form.description);
  1633. }
  1634. }, 200);
  1635. if(this.form.image!=null){
  1636. this.imageArr=this.form.image.split(",");
  1637. }
  1638. if(this.form.sliderImage!=null){
  1639. this.photoArr=this.form.sliderImage.split(",");
  1640. }
  1641. this.open = true;
  1642. this.title = "修改商品";
  1643. });
  1644. },
  1645. /** 提交按钮 */
  1646. submitForm() {
  1647. this.$refs["form"].validate(valid => {
  1648. if (valid) {
  1649. if(this.form.specType ===0 ){
  1650. this.form.items = [];
  1651. this.form.values = this.oneFormValidate;
  1652. }else{
  1653. this.form.items = this.attrs;
  1654. this.form.values = this.manyFormValidate;
  1655. }
  1656. if(this.form.specType === 1 && this.manyFormValidate.length===0){
  1657. return this.$message.warning('请点击生成规格!');
  1658. }
  1659. // 组装companyIds
  1660. if (this.form.companyIds != null && this.form.companyIds != undefined) {
  1661. this.form.companyIds = this.form.companyIds.join(',');
  1662. }
  1663. // 小程序
  1664. const params = {
  1665. ...this.form,
  1666. appIds: this.appIds.join(',') // 数组转字符串
  1667. };
  1668. addOrEdit(params).then(response => {
  1669. if (response.code === 200) {
  1670. // 根据是否有productId判断是新增还是修改
  1671. if (this.form.productId) {
  1672. this.msgSuccess("修改成功");
  1673. } else {
  1674. this.msgSuccess("新增成功");
  1675. }
  1676. this.open = false;
  1677. this.getList();
  1678. }
  1679. }).catch(error => {
  1680. this.$message.error('请求失败: ' + error.message)
  1681. });
  1682. }
  1683. });
  1684. },
  1685. /** 删除按钮操作 */
  1686. handleDelete(row) {
  1687. const productIds = row.productId || this.ids;
  1688. this.$confirm('是否确认删除商品编号为"' + productIds + '"的数据项?', "警告", {
  1689. confirmButtonText: "确定",
  1690. cancelButtonText: "取消",
  1691. type: "warning"
  1692. }).then(function() {
  1693. return delStoreProduct(productIds);
  1694. }).then(() => {
  1695. this.getList();
  1696. this.msgSuccess("删除成功");
  1697. }).catch(function() {});
  1698. },
  1699. /** 复制按钮操作 */
  1700. bulkCopy(row) {
  1701. const productIds = row.productId || this.ids;
  1702. this.$confirm('是否确认复制商品编号为"' + productIds + '"的数据项?', "警告", {
  1703. confirmButtonText: "确定",
  1704. cancelButtonText: "取消",
  1705. type: "warning"
  1706. }).then(function() {
  1707. return bulkCopy(productIds);
  1708. }).then(() => {
  1709. this.getList();
  1710. this.msgSuccess("复制成功");
  1711. }).catch(function() {});
  1712. },
  1713. /** 导出按钮操作 */
  1714. handleExport() {
  1715. const queryParams = this.queryParams;
  1716. this.$confirm('是否确认导出所有商品数据项?', "警告", {
  1717. confirmButtonText: "确定",
  1718. cancelButtonText: "取消",
  1719. type: "warning"
  1720. }).then(function() {
  1721. return exportStoreProduct(queryParams);
  1722. }).then(response => {
  1723. this.download(response.msg);
  1724. }).catch(function() {});
  1725. }
  1726. }
  1727. };
  1728. </script>