index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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" clearable size="small">
  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 label="模板类型" prop="tempType">
  14. <el-select v-model="queryParams.tempType" placeholder="请选择模板类型" clearable size="small">
  15. <el-option
  16. v-for="dict in tempTypeOptions"
  17. :key="dict.dictValue"
  18. :label="dict.dictLabel"
  19. :value="dict.dictValue"
  20. />
  21. </el-select>
  22. </el-form-item> -->
  23. <el-form-item>
  24. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  25. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  26. </el-form-item>
  27. </el-form>
  28. <el-row :gutter="10" class="mb8">
  29. <el-col :span="1.5">
  30. <el-button
  31. type="primary"
  32. plain
  33. icon="el-icon-plus"
  34. size="mini"
  35. @click="handleAdd"
  36. v-hasPermi="['his:inquiryTemp:add']"
  37. >新增</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="success"
  42. plain
  43. icon="el-icon-edit"
  44. size="mini"
  45. :disabled="single"
  46. @click="handleUpdate"
  47. v-hasPermi="['his:inquiryTemp:edit']"
  48. >修改</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="danger"
  53. plain
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['his:inquiryTemp:remove']"
  59. >删除</el-button>
  60. </el-col>
  61. <el-col :span="1.5">
  62. <el-button
  63. type="warning"
  64. plain
  65. icon="el-icon-download"
  66. size="mini"
  67. :loading="exportLoading"
  68. @click="handleExport"
  69. v-hasPermi="['his:inquiryTemp:export']"
  70. >导出</el-button>
  71. </el-col>
  72. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  73. </el-row>
  74. <el-tabs type="card" v-model="actName" @tab-click="handleClickX">
  75. <el-tab-pane label="全部" name="10"></el-tab-pane>
  76. <el-tab-pane v-for="(item,index) in tempTypeOptions" :label="item.dictLabel" :name="item.dictValue"></el-tab-pane>
  77. </el-tabs>
  78. <el-table v-loading="loading" border :data="inquiryTempList" @selection-change="handleSelectionChange">
  79. <el-table-column type="selection" width="55" align="center" />
  80. <el-table-column label="标题" align="center" prop="title" />
  81. <el-table-column label="模板类型" align="center" prop="tempType">
  82. <template slot-scope="scope">
  83. <dict-tag :options="tempTypeOptions" :value="scope.row.tempType"/>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="排序号" align="center" prop="sort" />
  87. <el-table-column label="创建时间" align="center" prop="createTime" />
  88. <el-table-column label="修改时间" align="center" prop="updateTime" />
  89. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  90. <template slot-scope="scope">
  91. <el-button
  92. size="mini"
  93. type="text"
  94. icon="el-icon-edit"
  95. @click="handleUpdate(scope.row)"
  96. v-hasPermi="['his:inquiryTemp:edit']"
  97. >修改</el-button>
  98. <el-button
  99. size="mini"
  100. type="text"
  101. @click="handledetails(scope.row)"
  102. >详情
  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="['his:inquiryTemp: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="800px" append-to-body>
  123. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  124. <el-form-item label="标题" prop="title">
  125. <el-input v-model="form.title" placeholder="请输入标题" />
  126. </el-form-item>
  127. <el-form-item label="模板类型" prop="tempType">
  128. <el-select v-model="form.tempType" placeholder="请选择模板类型">
  129. <el-option
  130. v-for="dict in tempTypeOptions"
  131. :key="dict.dictValue"
  132. :label="dict.dictLabel"
  133. :value="parseInt(dict.dictValue)"
  134. ></el-option>
  135. </el-select>
  136. </el-form-item>
  137. <el-form-item label="排序号" prop="sort">
  138. <el-input-number v-model="form.sort" :min="0" label="请输入排序号"></el-input-number>
  139. </el-form-item>
  140. <el-row>
  141. <el-col :span="3"><div style="margin-top: 9px;font-weight: bold;float: right; margin-right: 15px;">选项</div></el-col>
  142. <el-col :span="21">
  143. <el-table :data="itemJson" :cell-style="{ textAlign: 'center' }" :header-cell-style="{textAlign: 'center'}" >
  144. <el-table-column label="标题" prop="name" >
  145. <template slot-scope="scope">
  146. <el-input v-model="scope.row.name" ></el-input>
  147. </template>
  148. </el-table-column>
  149. <el-table-column label="分值" prop="score" >
  150. <template slot-scope="scope">
  151. <el-input-number v-model="scope.row.score" controls-position="right" :min="0" size="small"></el-input-number>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="操作">
  155. <template slot-scope="scope">
  156. <el-button @click="deleteRow(scope.$index)" size="mini" type="text" v-if="itemJson.length>1">删除</el-button>
  157. <el-button @click="addRow" size="mini" type="text" >新增</el-button>
  158. </template>
  159. </el-table-column>
  160. </el-table>
  161. </el-col>
  162. </el-row>
  163. </el-form>
  164. <div slot="footer" class="dialog-footer">
  165. <el-button type="primary" @click="submitForm">确 定</el-button>
  166. <el-button @click="cancel">取 消</el-button>
  167. </div>
  168. </el-dialog>
  169. <el-drawer
  170. :with-header="false"
  171. size="75%"
  172. :title="show.title" :visible.sync="show.open">
  173. <inquiryTempDetails ref="Details" />
  174. </el-drawer>
  175. </div>
  176. </template>
  177. <script>
  178. import { listInquiryTemp, getInquiryTemp, delInquiryTemp, addInquiryTemp, updateInquiryTemp, exportInquiryTemp } from "@/api/his/inquiryTemp";
  179. import inquiryTempDetails from '../../components/his/inquiryTempDetails.vue';
  180. export default {
  181. name: "InquiryTemp",
  182. components: { inquiryTempDetails },
  183. data() {
  184. return {
  185. show:{
  186. open:false,
  187. },
  188. itemJson: [
  189. { name: "套餐1", score: "0"},
  190. ],
  191. actName:"10",
  192. // 遮罩层
  193. loading: true,
  194. // 导出遮罩层
  195. exportLoading: false,
  196. // 选中数组
  197. ids: [],
  198. // 非单个禁用
  199. single: true,
  200. // 非多个禁用
  201. multiple: true,
  202. // 显示搜索条件
  203. showSearch: true,
  204. // 总条数
  205. total: 0,
  206. // 模板表格数据
  207. inquiryTempList: [],
  208. // 弹出层标题
  209. title: "",
  210. // 是否显示弹出层
  211. open: false,
  212. // 模板类型字典
  213. tempTypeOptions: [],
  214. // 查询参数
  215. queryParams: {
  216. pageNum: 1,
  217. pageSize: 10,
  218. tempType: null,
  219. title: null,
  220. createTime: null,
  221. sort: null
  222. },
  223. // 表单参数
  224. form: {},
  225. // 表单校验
  226. rules: {
  227. tempType: [
  228. { required: true, message: "模板类型不能为空", trigger: "change" }
  229. ],
  230. title: [
  231. { required: true, message: "标题不能为空", trigger: "blur" }
  232. ],
  233. sort: [
  234. { required: true, message: "排序号不能为空", trigger: "blur" }
  235. ]
  236. }
  237. };
  238. },
  239. created() {
  240. this.getList();
  241. this.getDicts("sys_inquiry_temp_type").then(response => {
  242. this.tempTypeOptions = response.data;
  243. });
  244. },
  245. methods: {
  246. addRow() {
  247. this.itemJson.push({ name: "标题", score: "0"});
  248. },
  249. deleteRow(index) {
  250. this.itemJson.splice(index, 1);
  251. },
  252. /** 查询模板列表 */
  253. getList() {
  254. this.loading = true;
  255. listInquiryTemp(this.queryParams).then(response => {
  256. this.inquiryTempList = response.rows;
  257. this.total = response.total;
  258. this.loading = false;
  259. });
  260. },
  261. // 取消按钮
  262. cancel() {
  263. this.open = false;
  264. this.reset();
  265. },
  266. handleClickX(tab, event) {
  267. if(tab.name=="10"){
  268. this.queryParams.tempType=null;
  269. }else{
  270. this.queryParams.tempType=tab.name;
  271. }
  272. this.handleQuery();
  273. },
  274. // 表单重置
  275. reset() {
  276. this.form = {
  277. tempId: null,
  278. tempType: null,
  279. title: null,
  280. itemJson: null,
  281. createTime: null,
  282. updateTime: null,
  283. sort: null
  284. };
  285. this.resetForm("form");
  286. },
  287. /** 搜索按钮操作 */
  288. handleQuery() {
  289. this.queryParams.pageNum = 1;
  290. this.getList();
  291. },
  292. /** 重置按钮操作 */
  293. resetQuery() {
  294. this.resetForm("queryForm");
  295. this.handleQuery();
  296. },
  297. // 多选框选中数据
  298. handleSelectionChange(selection) {
  299. this.ids = selection.map(item => item.tempId)
  300. this.single = selection.length!==1
  301. this.multiple = !selection.length
  302. },
  303. /** 新增按钮操作 */
  304. handleAdd() {
  305. this.reset();
  306. this.open = true;
  307. this.title = "添加模板";
  308. this.priceJson=[
  309. { name: "标题", score: "0"},
  310. ];
  311. },
  312. /** 修改按钮操作 */
  313. handleUpdate(row) {
  314. this.reset();
  315. const tempId = row.tempId || this.ids
  316. getInquiryTemp(tempId).then(response => {
  317. this.form = response.data;
  318. this.open = true;
  319. this.title = "修改模板";
  320. this.itemJson=JSON.parse(this.form.itemJson)
  321. });
  322. },
  323. /** 提交按钮 */
  324. submitForm() {
  325. this.$refs["form"].validate(valid => {
  326. if (valid) {
  327. for (var i = 0; i < this.itemJson.length; i++) {
  328. if (!this.itemJson[i].name) {
  329. this.$message("标题不能为空")
  330. return;
  331. }
  332. }
  333. this.form.itemJson=JSON.stringify(this.itemJson )
  334. if (this.form.tempId != null) {
  335. updateInquiryTemp(this.form).then(response => {
  336. this.msgSuccess("修改成功");
  337. this.open = false;
  338. this.getList();
  339. });
  340. } else {
  341. addInquiryTemp(this.form).then(response => {
  342. this.msgSuccess("新增成功");
  343. this.open = false;
  344. this.getList();
  345. });
  346. }
  347. }
  348. });
  349. },
  350. handledetails(row){
  351. this.show.open=true;
  352. setTimeout(() => {
  353. this.$refs.Details.getDetails(row.tempId);
  354. }, 1);
  355. },
  356. /** 删除按钮操作 */
  357. handleDelete(row) {
  358. const tempIds = row.tempId || this.ids;
  359. this.$confirm('是否确认删除模板编号为"' + tempIds + '"的数据项?', "警告", {
  360. confirmButtonText: "确定",
  361. cancelButtonText: "取消",
  362. type: "warning"
  363. }).then(function() {
  364. return delInquiryTemp(tempIds);
  365. }).then(() => {
  366. this.getList();
  367. this.msgSuccess("删除成功");
  368. }).catch(() => {});
  369. },
  370. /** 导出按钮操作 */
  371. handleExport() {
  372. const queryParams = this.queryParams;
  373. this.$confirm('是否确认导出所有模板数据项?', "警告", {
  374. confirmButtonText: "确定",
  375. cancelButtonText: "取消",
  376. type: "warning"
  377. }).then(() => {
  378. this.exportLoading = true;
  379. return exportInquiryTemp(queryParams);
  380. }).then(response => {
  381. this.download(response.msg);
  382. this.exportLoading = false;
  383. }).catch(() => {});
  384. }
  385. }
  386. };
  387. </script>