index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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="productName">
  5. <el-input
  6. v-model="queryParams.productName"
  7. placeholder="请输入商品名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <!-- <el-form-item label="状态" prop="status">
  14. <el-select v-model="queryParams.status" placeholder="请选择状态 " clearable size="small">
  15. <el-option
  16. v-for="dict in statusOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item> -->
  23. <el-form-item label="创建时间" prop="createTime">
  24. <el-date-picker v-model="createTime" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" @change="change"></el-date-picker>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  28. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. <el-row :gutter="10" class="mb8">
  32. <el-col :span="1.5">
  33. <el-button
  34. type="danger"
  35. icon="el-icon-delete"
  36. size="mini"
  37. :disabled="multiple"
  38. @click="handleDelete"
  39. v-hasPermi="['store:storeProductYuyue:remove']"
  40. >删除</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="warning"
  45. icon="el-icon-download"
  46. size="mini"
  47. @click="handleExport"
  48. v-hasPermi="['store:storeProductYuyue:export']"
  49. >导出</el-button>
  50. </el-col>
  51. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  52. </el-row>
  53. <el-tabs type="card" v-model="queryParams.status" @tab-click="handleClick">
  54. <el-tab-pane label="待处理" name="0"></el-tab-pane>
  55. <el-tab-pane label="已处理" name="1"></el-tab-pane>
  56. </el-tabs>
  57. <el-table v-loading="loading" :data="storeProductYuyueList" @selection-change="handleSelectionChange">
  58. <el-table-column type="selection" width="55" align="center" />
  59. <el-table-column label="预约ID" align="center" prop="id" />
  60. <el-table-column label="用户ID" align="center" prop="userId" />
  61. <el-table-column label="会员昵称" align="center" prop="nickname" />
  62. <el-table-column label="会员电话" align="center" prop="phone" width="150px"/>
  63. <el-table-column label="状态 " align="center" prop="status" >
  64. <template slot-scope="scope">
  65. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="商品ID" align="center" prop="productId" />
  69. <el-table-column label="商品图片" align="center" width="120">
  70. <template slot-scope="scope">
  71. <el-popover
  72. placement="right"
  73. title=""
  74. trigger="hover"
  75. >
  76. <img slot="reference" :src="scope.row.image" width="100">
  77. <img :src="scope.row.image" style="max-width: 150px;">
  78. </el-popover>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
  82. <el-table-column label="分类" align="center" prop="cateName" />
  83. <el-table-column label="售价" align="center" prop="price" >
  84. <template slot-scope="scope" >
  85. <span v-if="scope.row.price!=null">{{scope.row.price.toFixed(2)}}</span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="库存" align="center" prop="stock" />
  89. <el-table-column label="类型" align="center" prop="productType" >
  90. <template slot-scope="scope">
  91. <el-tag prop="productType" v-for="(item, index) in productTypeOptions" v-if="scope.row.productType==item.dictValue">{{item.dictLabel}}</el-tag>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="创建时间" align="center" prop="createTime" width="180" />
  95. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="150px">
  96. <template slot-scope="scope">
  97. <el-button v-if="scope.row.status==0"
  98. size="mini"
  99. type="text"
  100. icon="el-icon-edit"
  101. @click="handleChuLi(scope.row)"
  102. v-hasPermi="['store:storeProductYuyue:edit']"
  103. >处理</el-button>
  104. <el-button
  105. size="mini"
  106. type="text"
  107. icon="el-icon-delete"
  108. @click="handleDelete(scope.row)"
  109. v-hasPermi="['store:storeProductYuyue:remove']"
  110. >删除</el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. <pagination
  115. v-show="total>0"
  116. :total="total"
  117. :page.sync="queryParams.pageNum"
  118. :limit.sync="queryParams.pageSize"
  119. @pagination="getList"
  120. />
  121. <!-- 添加或修改商品预约对话框 -->
  122. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  123. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  124. <el-form-item label="商品id" prop="productId">
  125. <el-input v-model="form.productId" placeholder="请输入商品id" />
  126. </el-form-item>
  127. <el-form-item label="用户id" prop="userId">
  128. <el-input v-model="form.userId" placeholder="请输入用户id" />
  129. </el-form-item>
  130. <el-form-item label="状态 ">
  131. <el-radio-group v-model="form.status">
  132. <el-radio
  133. v-for="dict in statusOptions"
  134. :key="dict.dictValue"
  135. :label="parseInt(dict.dictValue)"
  136. >{{dict.dictLabel}}</el-radio>
  137. </el-radio-group>
  138. </el-form-item>
  139. </el-form>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button type="primary" @click="submitForm">确 定</el-button>
  142. <el-button @click="cancel">取 消</el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { listStoreProductYuyue, getStoreProductYuyue, delStoreProductYuyue, addStoreProductYuyue, updateStoreProductYuyue, exportStoreProductYuyue } from "@/api/store/storeProductYuyue";
  149. export default {
  150. name: "StoreProductYuyue",
  151. data() {
  152. return {
  153. createTime:[],
  154. // 遮罩层
  155. loading: true,
  156. // 选中数组
  157. ids: [],
  158. // 非单个禁用
  159. single: true,
  160. // 非多个禁用
  161. multiple: true,
  162. // 显示搜索条件
  163. showSearch: true,
  164. // 总条数
  165. total: 0,
  166. // 商品预约表格数据
  167. storeProductYuyueList: [],
  168. // 弹出层标题
  169. title: "",
  170. // 是否显示弹出层
  171. open: false,
  172. // 0待处理1已处理 字典
  173. statusOptions: [],
  174. productTypeOptions: [],
  175. isShowOptions: [],
  176. // 查询参数
  177. queryParams: {
  178. pageNum: 1,
  179. pageSize: 10,
  180. productName: null,
  181. status: 0,
  182. startTime: null,
  183. endTime:null
  184. },
  185. // 表单参数
  186. form: {},
  187. // 表单校验
  188. rules: {
  189. }
  190. };
  191. },
  192. created() {
  193. this.getList();
  194. this.getDicts("fs_store_yuyue").then(response => {
  195. this.statusOptions = response.data;
  196. });
  197. this.getDicts("store_product_type").then((response) => {
  198. this.productTypeOptions = response.data;
  199. });
  200. this.getDicts("store_product_is_show").then((response) => {
  201. this.isShowOptions = response.data;
  202. });
  203. },
  204. methods: {
  205. change(){
  206. if(this.createTime!=null){
  207. this.queryParams.startTime=this.createTime[0];
  208. this.queryParams.endTime=this.createTime[1];
  209. }
  210. },
  211. /** 查询商品预约列表 */
  212. getList() {
  213. this.loading = true;
  214. console.log(this.createTime)
  215. listStoreProductYuyue(this.queryParams).then(response => {
  216. this.storeProductYuyueList = response.rows;
  217. this.total = response.total;
  218. this.loading = false;
  219. });
  220. },
  221. // 取消按钮
  222. cancel() {
  223. this.open = false;
  224. this.reset();
  225. },
  226. // 表单重置
  227. reset() {
  228. this.form = {
  229. productName: null,
  230. status: 0,
  231. startTime: null,
  232. endTime:null
  233. };
  234. this.createTime=null;
  235. this.resetForm("form");
  236. },
  237. /** 搜索按钮操作 */
  238. handleQuery() {
  239. this.queryParams.pageNum = 1;
  240. this.getList();
  241. },
  242. handleClick(){
  243. this.queryParams.pageNum = 1;
  244. this.getList();
  245. },
  246. /** 重置按钮操作 */
  247. resetQuery() {
  248. this.resetForm("queryForm");
  249. this.handleQuery();
  250. },
  251. // 多选框选中数据
  252. handleSelectionChange(selection) {
  253. this.ids = selection.map(item => item.id)
  254. this.single = selection.length!==1
  255. this.multiple = !selection.length
  256. },
  257. /** 新增按钮操作 */
  258. handleAdd() {
  259. this.reset();
  260. this.open = true;
  261. this.title = "添加商品预约";
  262. },
  263. /** 修改按钮操作 */
  264. handleUpdate(row) {
  265. this.reset();
  266. const id = row.id || this.ids
  267. getStoreProductYuyue(id).then(response => {
  268. this.form = response.data;
  269. this.open = true;
  270. this.title = "修改商品预约";
  271. });
  272. },
  273. handleChuLi(row){
  274. this.$confirm('是否确认已处理完成?', "警告", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning"
  278. }).then(function() {
  279. var fo={
  280. id:row.id,
  281. status:1,
  282. }
  283. return updateStoreProductYuyue(fo);
  284. }).then(() => {
  285. this.msgSuccess("修改成功");
  286. this.getList();
  287. }).catch(function() {});
  288. },
  289. /** 提交按钮 */
  290. submitForm() {
  291. this.$refs["form"].validate(valid => {
  292. if (valid) {
  293. if (this.form.id != null) {
  294. updateStoreProductYuyue(this.form).then(response => {
  295. if (response.code === 200) {
  296. this.msgSuccess("修改成功");
  297. this.open = false;
  298. this.getList();
  299. }
  300. });
  301. } else {
  302. addStoreProductYuyue(this.form).then(response => {
  303. if (response.code === 200) {
  304. this.msgSuccess("新增成功");
  305. this.open = false;
  306. this.getList();
  307. }
  308. });
  309. }
  310. }
  311. });
  312. },
  313. /** 删除按钮操作 */
  314. handleDelete(row) {
  315. const ids = row.id || this.ids;
  316. this.$confirm('是否确认删除商品预约编号为"' + ids + '"的数据项?', "警告", {
  317. confirmButtonText: "确定",
  318. cancelButtonText: "取消",
  319. type: "warning"
  320. }).then(function() {
  321. return delStoreProductYuyue(ids);
  322. }).then(() => {
  323. this.getList();
  324. this.msgSuccess("删除成功");
  325. }).catch(function() {});
  326. },
  327. /** 导出按钮操作 */
  328. handleExport() {
  329. const queryParams = this.queryParams;
  330. this.$confirm('是否确认导出所有商品预约数据项?', "警告", {
  331. confirmButtonText: "确定",
  332. cancelButtonText: "取消",
  333. type: "warning"
  334. }).then(function() {
  335. return exportStoreProductYuyue(queryParams);
  336. }).then(response => {
  337. this.download(response.msg);
  338. }).catch(function() {});
  339. }
  340. }
  341. };
  342. </script>