ask.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div id="ask">
  3. <search-box-new
  4. ref="searchBox"
  5. :formData="formData"
  6. :formList="formList"
  7. @search="search"
  8. @init="init"
  9. />
  10. <table-list
  11. :tableSets="tableSet"
  12. :tableData="tableData"
  13. :navText="navText"
  14. :loading="loading"
  15. >
  16. <template slot="btn" slot-scope="props">
  17. <el-button type="text" @click="reply(props.scope.row)">回复</el-button>
  18. <el-button type="text" @click="del(props.scope.row)">删除</el-button>
  19. </template>
  20. </table-list>
  21. <pagination
  22. :total="total"
  23. :pageSize="formData.pageSize"
  24. :currentPage="formData.pageNum"
  25. @handleSizeChange="handleSizeChange"
  26. @handleCurrentChange="handleCurrentChange"
  27. />
  28. <el-dialog
  29. :visible.sync="dialogVisible"
  30. width="610px"
  31. :show-close="false"
  32. :close-on-click-modal="false"
  33. >
  34. <div slot="title" class="hearders">
  35. <div class="leftTitle">回复</div>
  36. <div class="rightBoxs">
  37. <img src="@/assets/images/Close@2x.png" alt="" @click="closeBZ" />
  38. </div>
  39. </div>
  40. <div>
  41. <el-form
  42. label-position="right"
  43. label-width="150px"
  44. :model="listData"
  45. :rules="rules"
  46. ref="listData"
  47. >
  48. <el-form-item label="问题内容">
  49. <span>{{ listData.content }}</span>
  50. </el-form-item>
  51. <el-form-item label="回复内容" prop="answerText">
  52. <el-input type="textarea" v-model="listData.answerText"></el-input>
  53. </el-form-item>
  54. </el-form>
  55. </div>
  56. <span slot="footer" class="dialog-footer">
  57. <el-button @click="closeBZ">取 消</el-button>
  58. <el-button @click="submitForm('listData')">确 定</el-button>
  59. </span>
  60. </el-dialog>
  61. </div>
  62. </template>
  63. <script>
  64. import searchBoxNew from "@/components/searchBoxNew";
  65. import tableList from "@/components/tableList";
  66. import pagination from "@/components/pagination";
  67. export default {
  68. name: "ask",
  69. components: { searchBoxNew, tableList, pagination },
  70. data() {
  71. return {
  72. loading: false, //当前表单加载是否加载动画
  73. navText: {
  74. title: "提问信息",
  75. index: 0,
  76. ch: "条",
  77. num: false,
  78. border: true,
  79. choice: true,
  80. addHide: true,
  81. backFatherBtn: {
  82. status: false,
  83. title: "未定义",
  84. },
  85. },
  86. //搜索
  87. formList: [
  88. {
  89. prop: "educationTypeId",
  90. placeholder: "教育类型",
  91. scope: "educationType",
  92. },
  93. {
  94. prop: "businessId",
  95. placeholder: "业务层次",
  96. scope: "businessLevel",
  97. edu: "educationTypeId",
  98. },
  99. {
  100. prop: "searchKey",
  101. placeholder: "请输入商品标题/提问内容",
  102. },
  103. ],
  104. formData: {
  105. status: 1,
  106. pageSize: 10,
  107. msgType: 1,
  108. pageNum: 1,
  109. },
  110. // 表单
  111. tableSet: [
  112. {
  113. label: "教育类型",
  114. prop: "educationName",
  115. hidden: true,
  116. },
  117. {
  118. label: "业务层次",
  119. prop1: "projectName",
  120. prop2: "businessName",
  121. hidden: true,
  122. scope: "InfoMore",
  123. },
  124. {
  125. label: "商品名称",
  126. prop: "goodsName",
  127. hidden: true,
  128. },
  129. {
  130. label: "提问内容",
  131. prop: "answerText",
  132. hidden: true,
  133. width:"250px"
  134. },
  135. {
  136. label: "提问人",
  137. prop: "realname",
  138. hidden: true,
  139. },
  140. {
  141. label: "提问时间",
  142. prop: "createTime",
  143. hidden: true,
  144. scope: "aTimeList",
  145. },
  146. ],
  147. tableData: [], //表单数据
  148. total: 0, //一共多少条
  149. listData: {
  150. answerText: "",
  151. },
  152. rules: {
  153. answerText: [
  154. { required: true, message: "请输入回复内容", trigger: "blur" },
  155. ],
  156. },
  157. dialogVisible: false,
  158. };
  159. },
  160. activated() {
  161. this.search();
  162. },
  163. methods: {
  164. search(int) {
  165. this.loading = true;
  166. if (int === 1) {
  167. this.formData.pageNum = 1;
  168. }
  169. if (int === 2) {
  170. this.formData = {
  171. status: 1,
  172. pageSize: 10,
  173. pageNum: 1,
  174. msgType: 1,
  175. };
  176. }
  177. if (int === 3) {
  178. this.formData.pageNum = 1;
  179. }
  180. var data = JSON.parse(JSON.stringify(this.formData));
  181. data.sort = 0
  182. this.$api
  183. .inquirecourseanswerlist(data)
  184. .then((res) => {
  185. this.tableData = res.rows;
  186. this.total = res.total;
  187. this.navText.index = res.total;
  188. })
  189. .finally(() => {
  190. this.loading = false;
  191. });
  192. },
  193. init() {
  194. this.search(2);
  195. },
  196. del(v) {
  197. this.$alert(
  198. "确定删除此内容?<br />内容删除后将无法恢复,请慎重考虑",
  199. "提示",
  200. {
  201. dangerouslyUseHTMLString: true,
  202. }
  203. )
  204. .then(() => {
  205. var data = {
  206. answerId: v.answerId,
  207. status: -1,
  208. };
  209. this.$api.editcourseanswer(data).then((res) => {
  210. this.$message.success("删除成功");
  211. this.search();
  212. });
  213. })
  214. .catch(() => {
  215. this.$message({
  216. type: "info",
  217. message: "已取消删除",
  218. });
  219. });
  220. },
  221. handleSizeChange(v) {
  222. this.formData.pageSize = v;
  223. this.formData.pageNum = 1;
  224. this.search();
  225. },
  226. handleCurrentChange(v) {
  227. this.formData.pageNum = v;
  228. this.search();
  229. },
  230. reply(item) {
  231. var data = JSON.parse(JSON.stringify(item));
  232. data.content = item.answerText;
  233. data.answerText = "";
  234. data.assignAnswerId = item.answerId;
  235. data.userId = 0;
  236. data.assignAvatar = item.avatar;
  237. data.assignRealname = item.realname;
  238. data.assignUserId = item.userId;
  239. delete data.answerId;
  240. this.listData = data;
  241. this.dialogVisible = true;
  242. },
  243. closeBZ() {
  244. this.$nextTick(() => {
  245. this.$refs["listData"].resetFields();
  246. });
  247. this.dialogVisible = false;
  248. },
  249. /**
  250. * 提交-表单验证
  251. */
  252. submitForm(formName) {
  253. this.$refs[formName].validate((valid) => {
  254. if (valid) {
  255. this.submit();
  256. } else {
  257. console.log("error submit!!");
  258. return false;
  259. }
  260. });
  261. },
  262. submit() {
  263. this.$api.addcourseanswer(this.listData).then((res) => {
  264. this.$message.success("回复成功");
  265. this.search();
  266. this.dialogVisible = false;
  267. });
  268. },
  269. },
  270. };
  271. </script>
  272. <style lang="less" scoped>
  273. /deep/.el-button {
  274. border-radius: 8px;
  275. }
  276. /deep/.el-dialog {
  277. border-radius: 8px;
  278. .el-dialog__header {
  279. padding: 0;
  280. .hearders {
  281. height: 40px;
  282. display: flex;
  283. align-items: center;
  284. justify-content: space-between;
  285. padding: 0px 18px 0px 20px;
  286. border-bottom: 1px solid #e2e2e2;
  287. .leftTitle {
  288. font-size: 14px;
  289. font-weight: bold;
  290. color: #2f4378;
  291. }
  292. .rightBoxs {
  293. display: flex;
  294. align-items: center;
  295. img {
  296. width: 14px;
  297. height: 14px;
  298. margin-left: 13px;
  299. cursor: pointer;
  300. }
  301. }
  302. }
  303. }
  304. .el-dialog__footer {
  305. padding: 0;
  306. .dialog-footer {
  307. padding: 0px 40px;
  308. height: 70px;
  309. border-top: 1px solid #e2e2e2;
  310. display: flex;
  311. align-items: center;
  312. justify-content: flex-end;
  313. }
  314. }
  315. }
  316. .imgBox {
  317. width: 100%;
  318. // height: 210px;
  319. border: 1px solid #e2e2e2;
  320. border-radius: 8px;
  321. padding: 8px 8px 3px;
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. .imgLabel {
  326. flex: 1;
  327. width: 100%;
  328. border: 1px dotted #e2e2e2;
  329. color: #999;
  330. font-size: 14px;
  331. cursor: pointer;
  332. border-radius: 8px;
  333. .msPhoto {
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. max-width: 100%;
  338. max-height: 270px;
  339. img {
  340. max-width: 100%;
  341. max-height: 270px;
  342. }
  343. }
  344. .imgbbx {
  345. display: flex;
  346. flex-direction: column;
  347. align-items: center;
  348. justify-content: center;
  349. width: 100%;
  350. height: 100%;
  351. i {
  352. font-weight: bold;
  353. margin: 14px 0;
  354. font-size: 24px;
  355. }
  356. }
  357. }
  358. p {
  359. margin: 5px 0px;
  360. }
  361. }
  362. </style>