index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <!--大屏计划-->
  2. <template>
  3. <div class="app-container labNotifyplan">
  4. <div class="labNotifyplan-page" v-if="pageType == 1">
  5. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  6. <el-form-item label="关键字" prop="searchValue">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="标题/发布单位/发布人"
  10. clearable
  11. size="small"
  12. />
  13. </el-form-item>
  14. <el-form-item label="发布时间" prop="createTimeDate" label-width="80px">
  15. <el-date-picker
  16. :clearable="false"
  17. v-model="createTimeDate"
  18. size="small"
  19. style="width: 240px"
  20. value-format="yyyy-MM-dd"
  21. type="daterange"
  22. range-separator="-"
  23. start-placeholder="开始日期"
  24. end-placeholder="结束日期"
  25. ></el-date-picker>
  26. </el-form-item>
  27. <el-form-item style="float: right;">
  28. <el-col :span="1.5">
  29. <p class="add-button-one-120"
  30. @click="pageTypeClick(2)"
  31. v-hasPermi="['laboratory:worknotifyplan:add']"
  32. >新增</p>
  33. </el-col>
  34. </el-form-item>
  35. <el-form-item>
  36. <p class="inquire-button-one" @click="handleQuery">查询</p>
  37. <p class="reset-button-one" @click="resetQuery">重置</p>
  38. </el-form-item>
  39. </el-form>
  40. <el-table v-loading="loading" border :data="notifyplanList" @selection-change="handleSelectionChange">
  41. <!--<el-table-column type="selection" width="55" align="center" />-->
  42. <!--<el-table-column label="主键" align="center" prop="id" />-->
  43. <el-table-column label="标题" align="left" prop="title" />
  44. <el-table-column label="发布单位" align="left" prop="company" />
  45. <el-table-column label="发布人" align="left" prop="createBy" />
  46. <el-table-column label="发布时间" align="left" prop="createTime" />
  47. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160" v-if="tableButtonType">
  48. <template slot-scope="scope">
  49. <div class="button-box" style="display: flex">
  50. <p class="table-min-button"
  51. style="margin-right: 10px"
  52. @click="pageTypeClick(3,scope.row)"
  53. v-hasPermi="['laboratory:worknotifyplan:query']"
  54. >查看</p>
  55. <p class="table-min-button"
  56. style="margin-right: 10px"
  57. @click="handleDelete(scope.row)"
  58. v-hasPermi="['laboratory:worknotifyplan:remove']"
  59. >删除</p>
  60. </div>
  61. </template>
  62. </el-table-column>
  63. </el-table>
  64. <pagination :page-sizes="[20, 30, 40, 50]"
  65. v-show="total>0"
  66. :total="total"
  67. :page.sync="queryParams.pageNum"
  68. :limit.sync="queryParams.pageSize"
  69. @pagination="getList"
  70. />
  71. </div>
  72. <add-page v-if="pageType == 2"></add-page>
  73. <info-page v-if="pageType == 3" :infoData="infoData"></info-page>
  74. <!-- 添加或修改大屏通知计划对话框 -->
  75. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  76. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  77. <el-form-item label="标题" prop="title">
  78. <el-input v-model="form.title" maxLength="12" placeholder="请输入通知标题" style="width:330px;" :disabled="lookType"/>
  79. </el-form-item>
  80. <el-form-item label="发布单位" prop="company">
  81. <el-input v-model="form.company" maxLength="12" placeholder="请输入发布单位" style="width:330px;" :disabled="lookType"/>
  82. </el-form-item>
  83. <el-form-item label="内容" prop="content" v-if="!lookType">
  84. <el-upload
  85. style="display: inline-block"
  86. class="avatar-uploader"
  87. :action="uploadImgUrl"
  88. :show-file-list="false"
  89. :on-success="(res)=>handleAvatarSuccess(res)"
  90. :headers="headers"
  91. :before-upload="beforeAvatarUpload">
  92. <p class="reset-button-one left-button" style="width:160px;"><i class="el-icon-upload2" style="margin-right:10px;"></i>请上传文件</p>
  93. </el-upload>
  94. <a href="" style="display: inline-block;margin-left:20px;color:#0E9EED;">下载范例</a>
  95. </el-form-item>
  96. <p v-if="form.content&&!lookType" style="display:inline-block;margin:0 0 0 80px;text-align:center;height:30px;line-height:30px;font-size:14px;padding:0 20px;border-radius:6px;color:#fff;background:#0E9EED;">{{upDataName}}</p>
  97. <a v-if="form.content&&lookType" :href="form.content" style="display:inline-block;margin:0 0 0 80px;text-align:center;height:30px;line-height:30px;font-size:14px;padding:0 20px;border-radius:6px;color:#fff;background:#0E9EED;">Excel文件</a>
  98. </el-form>
  99. <div slot="footer" class="dialog-footer">
  100. <el-button @click="cancel">取 消</el-button>
  101. <el-button type="primary" @click="submitForm" v-if="!lookType">确 定</el-button>
  102. </div>
  103. </el-dialog>
  104. </div>
  105. </template>
  106. <script>
  107. import { notifyplanListJh, getNotifyplan, delNotifyplan, addNotifyplan, updateNotifyplan } from "@/api/laboratory/notifyplan";
  108. import { getToken } from "@/utils/auth";
  109. import addPage from "./addPage.vue"
  110. import infoPage from "./infoPage.vue"
  111. export default {
  112. name: "Notifyplan",
  113. components: {
  114. addPage,
  115. infoPage
  116. },
  117. data() {
  118. return {
  119. tableButtonType:this.hasPermiDom(['laboratory:worknotifyplan:query','laboratory:worknotifyplan:remove']),
  120. pageType:1,
  121. uploadImgUrl: this.uploadUrl(), // 上传的图片服务器地址
  122. headers: {
  123. Authorization: "Bearer " + getToken(),
  124. },
  125. // 遮罩层
  126. loading: true,
  127. // 选中数组
  128. ids: [],
  129. // 非单个禁用
  130. single: true,
  131. // 非多个禁用
  132. multiple: true,
  133. // 显示搜索条件
  134. showSearch: true,
  135. // 总条数
  136. total: 0,
  137. // 大屏通知计划表格数据
  138. notifyplanList: [],
  139. // 弹出层标题
  140. title: "",
  141. // 是否显示弹出层
  142. open: false,
  143. // 查询参数
  144. queryParams: {
  145. pageNum: 1,
  146. pageSize:20,
  147. searchValue: null,
  148. title: null,
  149. notifyType: null,
  150. type: null,
  151. contentName: null,
  152. contentUrl: null,
  153. content: null,
  154. company: null,
  155. status: null,
  156. createUserid: null,
  157. createUsername: null,
  158. updateUserid: null,
  159. updateUsername: null,
  160. },
  161. createTimeDate:[],
  162. // 表单参数
  163. form: {},
  164. // 表单校验
  165. rules: {
  166. title: [
  167. { required: true, message: "请输入通知标题", trigger: "blur" },
  168. { required: true, message: "请输入通知标题", validator: this.spaceJudgment, trigger: "blur" }
  169. ],
  170. company: [
  171. { required: true, message: "请输入发布单位", trigger: "blur" },
  172. { required: true, message: "请输入发布单位", validator: this.spaceJudgment, trigger: "blur" }
  173. ],
  174. content: [
  175. { required: true, message: "请上传文件", trigger: "blur" }
  176. ],
  177. },
  178. lookType:false,
  179. upDataName:"",
  180. };
  181. },
  182. created() {
  183. this.getList();
  184. },
  185. methods: {
  186. pageTypeClick(type,row){
  187. if(this.pageType != type){
  188. if(type == 1){
  189. this.pageType = 1;
  190. this.getList();
  191. }else if(type == 2){
  192. this.pageType = 2;
  193. }else if(type == 3){
  194. this.pageType = 3;
  195. this.infoData = row;
  196. }
  197. }
  198. },
  199. //上传相关
  200. handleAvatarSuccess(res) {
  201. let obj ={
  202. name:this.upDataName,
  203. url:res.data.url,
  204. };
  205. this.form.content = res.data.url;
  206. this.$forceUpdate()
  207. },
  208. beforeAvatarUpload(file) {
  209. let type = false;
  210. console.log('file',file);
  211. if (file.type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type == 'application/vnd.ms-excel') {
  212. this.upDataName = file.name;
  213. type = true;
  214. }else{
  215. this.$message.error('只能上传xls或xlsx格式表格');
  216. type = false;
  217. }
  218. return type;
  219. },
  220. /** 查询大屏通知计划列表 */
  221. getList() {
  222. if(this.createTimeDate[0]){
  223. this.queryParams.beginTime = this.createTimeDate[0];
  224. this.queryParams.endTime = this.createTimeDate[1];
  225. }else {
  226. this.queryParams.beginTime = null
  227. this.queryParams.endTime = null
  228. }
  229. this.loading = true;
  230. this.queryParams.type = 2;
  231. notifyplanListJh(this.queryParams).then( response => {
  232. this.notifyplanList = response.rows;
  233. this.total = response.total;
  234. this.loading = false;
  235. });
  236. },
  237. // 取消按钮
  238. cancel() {
  239. this.open = false;
  240. this.reset();
  241. },
  242. // 表单重置
  243. reset() {
  244. // 表单参数
  245. this.form = {
  246. id: null,
  247. title: null,
  248. company: null,
  249. content: null,
  250. type:1,
  251. };
  252. this.resetForm("form");
  253. this.$forceUpdate();
  254. },
  255. /** 搜索按钮操作 */
  256. handleQuery() {
  257. this.queryParams.pageNum = 1;
  258. this.getList();
  259. },
  260. /** 重置按钮操作 */
  261. resetQuery() {
  262. this.createTimeDate = []
  263. // this.resetForm("queryForm");
  264. this.$set(this,'queryParams',{
  265. pageNum: 1,
  266. pageSize:20,
  267. searchValue:"",
  268. });
  269. this.handleQuery();
  270. },
  271. // 多选框选中数据
  272. handleSelectionChange(selection) {
  273. this.ids = selection.map(item => item.id)
  274. this.single = selection.length!==1
  275. this.multiple = !selection.length
  276. },
  277. /** 新增按钮操作 */
  278. handleAdd() {
  279. // let obj = {
  280. // title:"",
  281. // company:"",
  282. // content:"",
  283. // }
  284. // this.$set(this,'form',obj);
  285. this.lookType = false;
  286. this.open = true;
  287. this.reset();
  288. this.title = "新增计划";
  289. },
  290. /** 修改按钮操作 */
  291. handleUpdate(row) {
  292. const id = row.id || this.ids
  293. getNotifyplan(id).then( response => {
  294. // this.form = response.data;
  295. this.open = true;
  296. this.lookType = true;
  297. this.reset();
  298. this.$set(this,'form',response.data);
  299. this.title = "计划详情";
  300. });
  301. },
  302. /** 提交按钮 */
  303. submitForm() {
  304. this.$refs["form"].validate(valid => {
  305. if (valid) {
  306. if (this.form.id != null) {
  307. updateNotifyplan(this.form).then( response => {
  308. this.msgSuccess("修改成功");
  309. this.open = false;
  310. this.getList();
  311. });
  312. } else {
  313. this.form.type = 2;
  314. addNotifyplan(this.form).then( response => {
  315. this.msgSuccess("新增成功");
  316. this.open = false;
  317. this.getList();
  318. });
  319. }
  320. }
  321. });
  322. },
  323. /** 删除按钮操作 */
  324. handleDelete(row) {
  325. const ids = row.id || this.ids;
  326. this.$confirm('是否确认删除?', "警告", {
  327. confirmButtonText: "确定",
  328. cancelButtonText: "取消",
  329. type: "warning"
  330. }).then(function() {
  331. return delNotifyplan(ids);
  332. }).then(() => {
  333. this.getList();
  334. this.msgSuccess("删除成功");
  335. }).catch(() => {});
  336. },
  337. /** 导出按钮操作 */
  338. handleExport() {
  339. this.download('laboratory/notifyplan/export', {
  340. ...this.queryParams
  341. }, `laboratory_notifyplan.xlsx`)
  342. }
  343. }
  344. };
  345. </script>
  346. <style scoped lang="scss">
  347. .labNotifyplan{
  348. display: flex !important;
  349. flex-direction: column;
  350. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  351. overflow: hidden;
  352. .labNotifyplan-page{
  353. flex:1;
  354. display: flex !important;
  355. flex-direction: column;
  356. padding:11px 20px 20px!important;
  357. overflow: hidden;
  358. }
  359. }
  360. </style>