index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="满意度" prop="verySatisfied">
  5. <el-input
  6. v-model="queryParams.verySatisfied"
  7. placeholder="请输入满意度"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <!-- <el-form-item label="数量" prop="satisfied">-->
  13. <!-- <el-input-->
  14. <!-- v-model="queryParams.satisfiedNum"-->
  15. <!-- placeholder="请输入满意"-->
  16. <!-- clearable-->
  17. <!-- @keyup.enter.native="handleQuery"-->
  18. <!-- />-->
  19. <!-- </el-form-item>-->
  20. <!-- <el-form-item label="基本满意" prop="somewhatSatisfied">-->
  21. <!-- <el-input-->
  22. <!-- v-model="queryParams.somewhatSatisfied"-->
  23. <!-- placeholder="请输入基本满意"-->
  24. <!-- clearable-->
  25. <!-- @keyup.enter.native="handleQuery"-->
  26. <!-- />-->
  27. <!-- </el-form-item>-->
  28. <!-- <el-form-item label="不满意" prop="dissatisfied">-->
  29. <!-- <el-input-->
  30. <!-- v-model="queryParams.dissatisfied"-->
  31. <!-- placeholder="请输入不满意"-->
  32. <!-- clearable-->
  33. <!-- @keyup.enter.native="handleQuery"-->
  34. <!-- />-->
  35. <!-- </el-form-item>-->
  36. <!-- <el-form-item label="非常不满意" prop="veryDissatisfied">-->
  37. <!-- <el-input-->
  38. <!-- v-model="queryParams.veryDissatisfied"-->
  39. <!-- placeholder="请输入非常不满意"-->
  40. <!-- clearable-->
  41. <!-- @keyup.enter.native="handleQuery"-->
  42. <!-- />-->
  43. <!-- </el-form-item>-->
  44. <el-form-item>
  45. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  46. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  47. </el-form-item>
  48. </el-form>
  49. <el-row :gutter="10" class="mb8">
  50. <el-col :span="1.5">
  51. <el-button
  52. type="primary"
  53. plain
  54. icon="el-icon-plus"
  55. size="mini"
  56. @click="handleAdd"
  57. v-hasPermi="['system:review:add']"
  58. >新增
  59. </el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="success"
  64. plain
  65. icon="el-icon-edit"
  66. size="mini"
  67. :disabled="single"
  68. @click="handleUpdate"
  69. v-hasPermi="['system:review:edit']"
  70. >修改
  71. </el-button>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-button
  75. type="danger"
  76. plain
  77. icon="el-icon-delete"
  78. size="mini"
  79. :disabled="multiple"
  80. @click="handleDelete"
  81. v-hasPermi="['system:review:remove']"
  82. >删除
  83. </el-button>
  84. </el-col>
  85. <!-- <el-col :span="1.5">-->
  86. <!-- <el-button-->
  87. <!-- type="warning"-->
  88. <!-- plain-->
  89. <!-- icon="el-icon-download"-->
  90. <!-- size="mini"-->
  91. <!-- @click="handleExport"-->
  92. <!-- v-hasPermi="['system:review:export']"-->
  93. <!-- >导出-->
  94. <!-- </el-button>-->
  95. <!-- </el-col>-->
  96. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  97. </el-row>
  98. <el-table v-loading="loading" :data="reviewList" @selection-change="handleSelectionChange">
  99. <el-table-column type="selection" width="55" align="center"/>
  100. <!-- <el-table-column label="主键id" align="center" prop="id"/>-->
  101. <el-table-column label="满意度" align="center" prop="verySatisfied"/>
  102. <el-table-column label="数量" align="center" prop="satisfiedNum"/>
  103. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  104. <template slot-scope="scope">
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-edit"
  109. @click="handleUpdate(scope.row)"
  110. v-hasPermi="['system:review:edit']"
  111. >修改
  112. </el-button>
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-delete"
  117. @click="handleDelete(scope.row)"
  118. v-hasPermi="['system:review:remove']"
  119. >删除
  120. </el-button>
  121. </template>
  122. </el-table-column>
  123. </el-table>
  124. <pagination
  125. v-show="total>0"
  126. :total="total"
  127. :page.sync="queryParams.pageNum"
  128. :limit.sync="queryParams.pageSize"
  129. @pagination="getList"
  130. />
  131. <!-- 添加或修改好差评对话框 -->
  132. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  133. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  134. <el-form-item label="满意度" prop="verySatisfied">
  135. <el-input v-model="form.verySatisfied" placeholder="请输入满意度" maxlength="10"/>
  136. </el-form-item>
  137. <el-form-item label="数量" prop="satisfiedNum">
  138. <el-input v-model="form.satisfiedNum" placeholder="请输入数量" maxlength="10"/>
  139. </el-form-item>
  140. </el-form>
  141. <div slot="footer" class="dialog-footer">
  142. <el-button type="primary" @click="submitForm">确 定</el-button>
  143. <el-button @click="cancel">取 消</el-button>
  144. </div>
  145. </el-dialog>
  146. </div>
  147. </template>
  148. <script>
  149. import {addReview, delReview, updateReview,getReview, listReview} from "@/api/system/review";
  150. import {checkNonnegativeInteger} from "@/api/system/rules";
  151. export default {
  152. name: "Review",
  153. data() {
  154. return {
  155. // 遮罩层
  156. loading: true,
  157. // 选中数组
  158. ids: [],
  159. // 非单个禁用
  160. single: true,
  161. // 非多个禁用
  162. multiple: true,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. total: 0,
  167. // 好差评表格数据
  168. reviewList: [],
  169. // 弹出层标题
  170. title: "",
  171. // 是否显示弹出层
  172. open: false,
  173. // 查询参数
  174. queryParams: {
  175. pageNum: 1,
  176. pageSize: 10,
  177. verySatisfied: null,
  178. satisfiedNum: null,
  179. },
  180. // 表单参数
  181. form: {},
  182. // 表单校验
  183. rules: {
  184. satisfiedNum: [
  185. { required: true, message: "数量不能为空", trigger: "change" },
  186. {validator: checkNonnegativeInteger, trigger: 'blur'}
  187. ],
  188. }
  189. };
  190. },
  191. created() {
  192. this.getList();
  193. },
  194. methods: {
  195. /** 查询好差评列表 */
  196. getList() {
  197. this.loading = true;
  198. listReview(this.queryParams).then(response => {
  199. this.reviewList = response.rows;
  200. this.total = response.total;
  201. this.loading = false;
  202. });
  203. },
  204. // 取消按钮
  205. cancel() {
  206. this.open = false;
  207. this.reset();
  208. },
  209. // 表单重置
  210. reset() {
  211. this.form = {
  212. id: null,
  213. verySatisfied: null,
  214. satisfiedNum: null,
  215. };
  216. this.resetForm("form");
  217. },
  218. /** 搜索按钮操作 */
  219. handleQuery() {
  220. this.queryParams.pageNum = 1;
  221. this.getList();
  222. },
  223. /** 重置按钮操作 */
  224. resetQuery() {
  225. this.resetForm("queryForm");
  226. this.handleQuery();
  227. },
  228. // 多选框选中数据
  229. handleSelectionChange(selection) {
  230. this.ids = selection.map(item => item.id)
  231. this.single = selection.length !== 1
  232. this.multiple = !selection.length
  233. },
  234. /** 新增按钮操作 */
  235. handleAdd() {
  236. this.reset();
  237. this.open = true;
  238. this.title = "添加好差评";
  239. },
  240. /** 修改按钮操作 */
  241. handleUpdate(row) {
  242. this.reset();
  243. const id = row.id || this.ids
  244. getReview(id).then(response => {
  245. this.form = response.data;
  246. this.open = true;
  247. this.title = "修改好差评";
  248. });
  249. },
  250. /** 提交按钮 */
  251. submitForm() {
  252. this.$refs["form"].validate(valid => {
  253. if (valid) {
  254. if (this.form.id !=null){
  255. updateReview(this.form).then(response => {
  256. this.$modal.msgSuccess("修改成功");
  257. this.open = false;
  258. this.getList();
  259. });
  260. }else{
  261. addReview(this.form).then(response => {
  262. this.$modal.msgSuccess("新增成功");
  263. this.open = false;
  264. this.getList();
  265. });
  266. }
  267. }
  268. });
  269. },
  270. /** 删除按钮操作 */
  271. handleDelete(row) {
  272. const ids = row.id || this.ids;
  273. this.$modal.confirm('是否确认删除好差评编号为"' + ids + '"的数据项?').then(function () {
  274. return delReview(ids);
  275. }).then(() => {
  276. this.getList();
  277. this.$modal.msgSuccess("删除成功");
  278. }).catch(() => {
  279. });
  280. },
  281. /** 导出按钮操作 */
  282. handleExport() {
  283. this.download('system/review/export', {
  284. ...this.queryParams
  285. }, `review_${new Date().getTime()}.xlsx`)
  286. }
  287. }
  288. }
  289. ;
  290. </script>