index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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="title">
  5. <el-input
  6. v-model="queryParams.title"
  7. placeholder="请输入活动标题"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item>
  14. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  15. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="primary"
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['store:storeActivity:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. icon="el-icon-edit"
  32. size="mini"
  33. :disabled="single"
  34. @click="handleUpdate"
  35. v-hasPermi="['store:storeActivity:edit']"
  36. >修改</el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="danger"
  41. icon="el-icon-delete"
  42. size="mini"
  43. :disabled="multiple"
  44. @click="handleDelete"
  45. v-hasPermi="['store:storeActivity:remove']"
  46. >删除</el-button>
  47. </el-col>
  48. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  49. </el-row>
  50. <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
  51. <el-tab-pane label="正常" name="1"></el-tab-pane>
  52. <el-tab-pane label="关闭" name="0"></el-tab-pane>
  53. </el-tabs>
  54. <el-table height="500" border v-loading="loading" :data="storeActivityList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center" />
  56. <el-table-column label="ID" align="center" prop="activityId" />
  57. <el-table-column label="活动标题" align="center" prop="title" />
  58. <!-- <el-table-column label="描述" show-overflow-tooltip align="center" prop="descs" /> -->
  59. <el-table-column label="弹框广告图" align="center" width="120">
  60. <template slot-scope="scope">
  61. <el-popover
  62. placement="right"
  63. title=""
  64. trigger="hover"
  65. >
  66. <img slot="reference" :src="scope.row.logoUrl" width="100">
  67. <img :src="scope.row.logoUrl" style="max-width: 150px;">
  68. </el-popover>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="分享数" align="center" prop="shareNumber" />
  72. <el-table-column label="状态" align="center" prop="status" >
  73. <template slot-scope="scope">
  74. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  78. <template slot-scope="scope">
  79. <el-button
  80. size="mini"
  81. type="text"
  82. icon="el-icon-edit"
  83. @click="handleUpdate(scope.row)"
  84. v-hasPermi="['store:storeActivity:edit']"
  85. >修改</el-button>
  86. <el-button
  87. size="mini"
  88. type="text"
  89. icon="el-icon-delete"
  90. @click="handleDelete(scope.row)"
  91. v-hasPermi="['store:storeActivity:remove']"
  92. >删除</el-button>
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. <pagination
  97. v-show="total>0"
  98. :total="total"
  99. :page.sync="queryParams.pageNum"
  100. :limit.sync="queryParams.pageSize"
  101. @pagination="getList"
  102. />
  103. <!-- 添加或修改活动对话框 -->
  104. <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
  105. <el-form ref="form" :model="form" :rules="rules" label-width="100px">
  106. <el-form-item label="标题" prop="title">
  107. <el-input v-model="form.title" placeholder="请输入标题" />
  108. </el-form-item>
  109. <!-- <el-form-item label="描述" prop="descs">
  110. <el-input v-model="form.descs" type="textarea" placeholder="请输入内容" />
  111. </el-form-item> -->
  112. <el-form-item label="弹框广告图" prop="logoUrl">
  113. <Material v-model="imageArr" type="image" :num="1" :width="150" :height="150" />
  114. </el-form-item>
  115. <el-form-item label="BANNER图" prop="images">
  116. <Material v-model="photoArr" type="image" :num="10" :width="150" :height="150" />
  117. </el-form-item>
  118. <el-form-item label="活动疗法" prop="productIds" >
  119. <el-row >
  120. <el-col >
  121. <el-button plain type="primary" icon="el-icon-plus" @click="handleAddPackage">添加疗法</el-button>
  122. </el-col>
  123. </el-row>
  124. <el-table border width="100%" style="margin-top:5px;" :data="packages">
  125. <el-table-column label="疗法ID" align="center" prop="packageId" />
  126. <el-table-column label="疗法图片" align="center" width="100">
  127. <template slot-scope="scope">
  128. <el-popover
  129. placement="right"
  130. title=""
  131. trigger="hover"
  132. >
  133. <img slot="reference" :src="scope.row.imgUrl" width="50">
  134. <img :src="scope.row.imgUrl" style="max-width: 50px;">
  135. </el-popover>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="疗法名称" show-overflow-tooltip align="center" prop="packageName" />
  139. <el-table-column label="售价" align="center" prop="price" >
  140. <template slot-scope="scope">
  141. <div v-if="scope.row.totalPrice!=null">
  142. {{scope.row.totalPrice.toFixed(2)}}
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="操作" align="center" width="100px" >
  147. <template slot-scope="scope">
  148. <el-button
  149. size="mini"
  150. type="text"
  151. icon="el-icon-delete"
  152. @click="handlePackageDelete(scope.row)"
  153. >删除</el-button>
  154. </template>
  155. </el-table-column>
  156. </el-table>
  157. </el-form-item>
  158. <el-form-item label="活动内容">
  159. <editor ref="myeditor" @on-text-change="updateText" />
  160. </el-form-item>
  161. <el-form-item label="状态">
  162. <el-radio-group v-model="form.status">
  163. <el-radio label="1">正常</el-radio>
  164. <el-radio label="0">关闭</el-radio>
  165. </el-radio-group>
  166. </el-form-item>
  167. </el-form>
  168. <div slot="footer" class="dialog-footer">
  169. <el-button type="primary" @click="submitForm">确 定</el-button>
  170. <el-button @click="cancel">取 消</el-button>
  171. </div>
  172. </el-dialog>
  173. <el-dialog :title="package.title" v-if="package.open" :visible.sync="package.open" width="1000px" append-to-body>
  174. <package-select ref="package" @selectPackage="selectPackage" />
  175. </el-dialog>
  176. </div>
  177. </template>
  178. <script>
  179. import { listStoreActivity, getStoreActivity, delStoreActivity, addStoreActivity, updateStoreActivity, exportStoreActivity } from "@/api/his/storeActivity";
  180. import Material from '@/components/Material'
  181. import singleImg from '@/components/Material/single'
  182. import Editor from '@/components/Editor/wang';
  183. import packageSelect from "./packageSelect";
  184. export default {
  185. name: "StoreActivity",
  186. components: {
  187. packageSelect,
  188. Editor,
  189. Material,
  190. singleImg,
  191. },
  192. watch: {
  193. imageArr: function(val) {
  194. this.form.logoUrl = val.join(',')
  195. },
  196. photoArr: function(val) {
  197. this.form.images = val.join(',')
  198. },
  199. },
  200. data() {
  201. return {
  202. photoArr:[],
  203. packages:[],
  204. package:{
  205. open:false,
  206. title:"疗法选择"
  207. },
  208. statusOptions:[],
  209. imageArr:[],
  210. activeName:"1",
  211. // 遮罩层
  212. loading: true,
  213. // 选中数组
  214. ids: [],
  215. // 非单个禁用
  216. single: true,
  217. // 非多个禁用
  218. multiple: true,
  219. // 显示搜索条件
  220. showSearch: true,
  221. // 总条数
  222. total: 0,
  223. // 活动表格数据
  224. storeActivityList: [],
  225. // 弹出层标题
  226. title: "",
  227. // 是否显示弹出层
  228. open: false,
  229. // 查询参数
  230. queryParams: {
  231. pageNum: 1,
  232. pageSize: 10,
  233. title: null,
  234. descs: null,
  235. logoUrl: null,
  236. images: null,
  237. productIds: null,
  238. content: null,
  239. status: null
  240. },
  241. // 表单参数
  242. form: {},
  243. // 表单校验
  244. rules: {
  245. }
  246. };
  247. },
  248. created() {
  249. this.getDicts("common_status").then((response) => {
  250. this.statusOptions = response.data;
  251. });
  252. this.getList();
  253. },
  254. methods: {
  255. selectPackage(row){
  256. for(var i=0;i<this.packages.length;i++){
  257. this.$message.warning('该疗法已存在,无需重复添加!');
  258. if(this.packages[i].packageId==row.packageId){
  259. return;
  260. }
  261. }
  262. this.packages.push(row);
  263. this.$message.success('疗法'+row.packageName+'添加成功!');
  264. },
  265. handleAddPackage(){
  266. this.package.open=true;
  267. },
  268. handlePackageDelete(row){
  269. this.packages.splice(this.packages.findIndex(item => item.packageId === row.packageId), 1)
  270. },
  271. updateText(text){
  272. this.form.content=text
  273. },
  274. handleClick(tab, event) {
  275. this.queryParams.status=tab.name;
  276. this.getList();
  277. },
  278. /** 查询活动列表 */
  279. getList() {
  280. this.loading = true;
  281. listStoreActivity(this.queryParams).then(response => {
  282. this.storeActivityList = response.rows;
  283. this.total = response.total;
  284. this.loading = false;
  285. });
  286. },
  287. // 取消按钮
  288. cancel() {
  289. this.open = false;
  290. this.reset();
  291. },
  292. // 表单重置
  293. reset() {
  294. this.form = {
  295. activityId: null,
  296. title: null,
  297. descs: null,
  298. logoUrl: null,
  299. images: null,
  300. packageIds: null,
  301. productIds: null,
  302. content: null,
  303. createTime: null,
  304. status: "1"
  305. };
  306. this.imageArr=[];
  307. this.photoArr=[];
  308. this.packages=[];
  309. this.packages=[];
  310. this.resetForm("form");
  311. },
  312. /** 搜索按钮操作 */
  313. handleQuery() {
  314. this.queryParams.pageNum = 1;
  315. this.getList();
  316. },
  317. /** 重置按钮操作 */
  318. resetQuery() {
  319. this.resetForm("queryForm");
  320. this.handleQuery();
  321. },
  322. // 多选框选中数据
  323. handleSelectionChange(selection) {
  324. this.ids = selection.map(item => item.activityId)
  325. this.single = selection.length!==1
  326. this.multiple = !selection.length
  327. },
  328. /** 新增按钮操作 */
  329. handleAdd() {
  330. this.reset();
  331. this.open = true;
  332. this.title = "添加活动";
  333. setTimeout(() => {
  334. this.$refs.myeditor.setText("");
  335. }, 200);
  336. },
  337. /** 修改按钮操作 */
  338. handleUpdate(row) {
  339. this.reset();
  340. const activityId = row.activityId || this.ids
  341. getStoreActivity(activityId).then(response => {
  342. this.form = response.activity;
  343. this.form.status=this.form.status.toString();
  344. if(this.form.logoUrl!=null){
  345. this.imageArr=this.form.logoUrl.split(',');
  346. }
  347. if(this.form.images!=null){
  348. this.photoArr=this.form.images.split(',');
  349. }
  350. this.packages=response.packages;
  351. this.open = true;
  352. this.title = "修改活动";
  353. setTimeout(() => {
  354. if(this.form.content==null){
  355. this.$refs.myeditor.setText("");
  356. }
  357. else{
  358. this.$refs.myeditor.setText(this.form.content);
  359. }
  360. }, 200);
  361. });
  362. },
  363. /** 提交按钮 */
  364. submitForm() {
  365. this.$refs["form"].validate(valid => {
  366. if (valid) {
  367. var packageIds=[];
  368. if (this.packages && this.packages.length>0) {
  369. this.packages.forEach(element => {
  370. packageIds.push(element.packageId);
  371. });
  372. // this.form.packageIds=packageIds.toString();
  373. this.form.productIds = packageIds.toString();
  374. } else {
  375. this.form.productIds = "";
  376. }
  377. if (this.form.activityId != null) {
  378. updateStoreActivity(this.form).then(response => {
  379. if (response.code === 200) {
  380. this.msgSuccess("修改成功");
  381. this.open = false;
  382. this.getList();
  383. }
  384. });
  385. } else {
  386. addStoreActivity(this.form).then(response => {
  387. if (response.code === 200) {
  388. this.msgSuccess("新增成功");
  389. this.open = false;
  390. this.getList();
  391. }
  392. });
  393. }
  394. }
  395. });
  396. },
  397. /** 删除按钮操作 */
  398. handleDelete(row) {
  399. const activityIds = row.activityId || this.ids;
  400. this.$confirm('是否确认删除活动编号为"' + activityIds + '"的数据项?', "警告", {
  401. confirmButtonText: "确定",
  402. cancelButtonText: "取消",
  403. type: "warning"
  404. }).then(function() {
  405. return delStoreActivity(activityIds);
  406. }).then(() => {
  407. this.getList();
  408. this.msgSuccess("删除成功");
  409. }).catch(function() {});
  410. },
  411. /** 导出按钮操作 */
  412. handleExport() {
  413. const queryParams = this.queryParams;
  414. this.$confirm('是否确认导出所有活动数据项?', "警告", {
  415. confirmButtonText: "确定",
  416. cancelButtonText: "取消",
  417. type: "warning"
  418. }).then(function() {
  419. return exportStoreActivity(queryParams);
  420. }).then(response => {
  421. this.download(response.msg);
  422. }).catch(function() {});
  423. }
  424. }
  425. };
  426. </script>