project.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="m_right">
  3. <view class="m_right_hander">
  4. <button size="mini" class="m_btn_red" @click="addProject()">添加项目</button>
  5. </view>
  6. <view class="m_right_container">
  7. <table style="width: 100%;border: 1px solid #DDDDDD;border-collapse: collapse">
  8. <thead class="m-table-hander">
  9. <tr>
  10. <!-- <th>
  11. <icon type="" style="color:#EA252C;" class="font_family" :class="checke?'icon-fuxuankuang_weixuanzhong4':'icon-fuxuankuang-true'"></icon>
  12. </th> -->
  13. <th>项目名称</th>
  14. <th>项目创建人</th>
  15. <th>项目创建时间</th>
  16. <th>项目描述</th>
  17. <!-- <th>项目推荐</th> -->
  18. <th>上线</th>
  19. <th>删除</th>
  20. </tr>
  21. </thead>
  22. <tbody>
  23. <tr v-for="(dataUser,dataUserI) in dataUsers_all" :key="dataUserI">
  24. <!-- <th>
  25. <icon type="" style="color:#EA252C;" class="font_family" :class="checke?'icon-fuxuankuang_weixuanzhong4':'icon-fuxuankuang-true'"></icon>
  26. </th> -->
  27. <th>{{dataUser.ProjectName}}</th>
  28. <th>{{dataUser.CreateUserName}}</th>
  29. <th>{{dataUser.CreateTime}}</th>
  30. <th>{{dataUser.Type}}</th>
  31. <!-- <th>{{dataUser.ProjectName}}</th> -->
  32. <th style="position: relative;"><button type="default" size="mini" class="m_online" @click="onlineProject(dataUser)">上线</button></th>
  33. <th style="position: relative;"><button type="default" size="mini" class="m_delete" @click="deleteProject(dataUser)">删除</button></th>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </view>
  38. <view class="m_right_footer">
  39. <view class="m_paging">
  40. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn">上一页</text>
  41. <text class="m_paging_item" :key="i" v-for="i in pageTotalNum" @click="paging(i)" :class="i==currentPage?'p_act':''">
  42. {{i}}
  43. </text>
  44. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn">下一页</text>
  45. </view>
  46. </view>
  47. <popForm ref="popForm"></popForm>
  48. <popAlert ref="popAlert"></popAlert>
  49. </view>
  50. </template>
  51. <script>
  52. import popForm from '@/components/popForm.vue'
  53. import popAlert from '@/components/popAlert.vue'
  54. export default {
  55. name: "project",
  56. components: {
  57. popForm,
  58. popAlert,
  59. },
  60. data() {
  61. return {
  62. pageTotalNum:1,
  63. currentPage:1,
  64. totalItem:2,
  65. dataUsers_all: [],
  66. checke: false,
  67. bShowLastPageBtn:false,
  68. bShowNextPageBtn:false,
  69. }
  70. },
  71. methods: {
  72. paging(i) {
  73. uni.showLoading({
  74. title: '加载中'
  75. });
  76. let fromIndex = this.totalItem*(i-1);
  77. let toIndex = fromIndex+this.totalItem;
  78. let data = {
  79. "UserID": mydata_userInfo.userID,
  80. "BeginNum": fromIndex, //用户数组索引
  81. "EndNum": toIndex, //用户数组索引结束
  82. "ItemType":""//道具 角色 场景 空为全部
  83. }
  84. uni.request({
  85. header: {
  86. 'Content-Type': 'application/json;charset=UTF-8'
  87. },
  88. url: mydata_api + '/backstage/getprojects',
  89. method: 'POST',
  90. data: data,
  91. dataType: 'json',
  92. success: (res) => {
  93. //100成功
  94. if (res.data.Code == 100) {
  95. console.log("请求全部项目", res);
  96. this.dataUsers_all = res.data.Projects;
  97. this.pageTotalNum = Math.ceil(res.data.AllNumOfList/this.totalItem);
  98. }
  99. //200失败
  100. else {
  101. console.log('suc200', res);
  102. }
  103. uni.hideLoading();
  104. this.showNextOrLastPageBtn();
  105. },
  106. fail: (res) => {
  107. console.log("请求失败****");
  108. uni.hideLoading();
  109. }
  110. });
  111. },
  112. initPage() {
  113. this.paging(1);
  114. },
  115. showNextOrLastPageBtn()
  116. {
  117. if((this.pageTotalNum-this.totalItem)>0)
  118. {
  119. this.bShowLastPageBtn = false;
  120. this.bShowNextPageBtn = false;
  121. // console.log('0000')
  122. }
  123. else if(this.pageTotalNum==this.currentPage)
  124. {
  125. this.bShowLastPageBtn = true;
  126. this.bShowNextPageBtn = false;
  127. // console.log('11111')
  128. }
  129. else if(1==this.currentPage)
  130. {
  131. this.bShowLastPageBtn = false;
  132. this.bShowNextPageBtn = true;
  133. // console.log('2222')
  134. }
  135. else
  136. {
  137. this.bShowLastPageBtn = true;
  138. this.bShowNextPageBtn = true;
  139. // console.log('333333')
  140. }
  141. },
  142. addProject()
  143. {
  144. uni.chooseFile({
  145. success: (chooseFileRes) =>
  146. {
  147. console.log('选择文件成功')
  148. const tempFilePaths = chooseFileRes.tempFilePaths;
  149. this.$refs.popForm.isShow(true);
  150. this.$refs.popForm.setTitle('添加项目');
  151. let _self = this;
  152. let callback = function(content_arr){
  153. let data = {
  154. "CreateUserID":mydata_userInfo.userID,
  155. "ProjectName":content_arr[0].input,
  156. "Describe":content_arr[1].input,
  157. "Type":content_arr[2].input,
  158. }
  159. uni.showLoading({
  160. title: '上传中'
  161. });
  162. uni.uploadFile({
  163. url: mydata_api + '/project/createprojectnew',
  164. filePath: tempFilePaths[0],
  165. name: 'file',
  166. formData:data,
  167. success: (uploadFileRes) => {
  168. console.log("创建项目成功", uploadFileRes);
  169. _self.paging(_self.currentPage);
  170. uni.hideLoading();
  171. },
  172. fail: (res) => {
  173. console.log("创建项目失败");
  174. uni.hideLoading();
  175. }
  176. });
  177. };
  178. this.$refs.popForm.setContent([
  179. {
  180. 'name':'项目名称',
  181. 'input':'',
  182. 'type' :'text'
  183. },
  184. {
  185. 'name':'项目描述',
  186. 'input':'',
  187. 'type' :'text'
  188. },
  189. {
  190. 'name':'项目类型',
  191. 'input':'',
  192. 'type' :'text'
  193. },
  194. ],callback);
  195. }
  196. });
  197. },
  198. onlineProject(dataUser)
  199. {
  200. // this.$refs.popAlert.isShow(true);
  201. // this.$refs.popAlert.setTitle('提示');
  202. // let _self = this;
  203. // let callback = function(){
  204. // let data = {
  205. // "UserID":mydata_userInfo.userID,
  206. // "ProjectID" : dataUser.Id.toString()
  207. // }
  208. // uni.showLoading({
  209. // title: '上线中'
  210. // });
  211. // uni.request({
  212. // header: {
  213. // 'Content-Type': 'application/json;charset=UTF-8'
  214. // },
  215. // url: mydata_api + '/backstage/deleteproject',
  216. // method: 'POST',
  217. // data: data,
  218. // dataType: 'json',
  219. // success: (res) => {
  220. // //100成功
  221. // if (res.data.Code == 100) {
  222. // console.log("上线成功", res);
  223. // _self.paging(_self.currentPage);
  224. // }
  225. // //200失败
  226. // else {
  227. // console.log('上线失败200', res);
  228. // }
  229. // uni.hideLoading();
  230. // },
  231. // fail: (res) => {
  232. // console.log("上线失败");
  233. // uni.hideLoading();
  234. // }
  235. // });
  236. // }
  237. // this.$refs.popAlert.setContent('是否删除项目',callback);
  238. },
  239. deleteProject(dataUser)
  240. {
  241. this.$refs.popAlert.isShow(true);
  242. this.$refs.popAlert.setTitle('提示');
  243. let _self = this;
  244. let callback = function(){
  245. let data = {
  246. "UserID":mydata_userInfo.userID,
  247. "ProjectID" : dataUser.Id.toString()
  248. }
  249. console.log('data=',data)
  250. uni.showLoading({
  251. title: '删除中'
  252. });
  253. uni.request({
  254. header: {
  255. 'Content-Type': 'application/json;charset=UTF-8'
  256. },
  257. url: mydata_api + '/backstage/deleteproject',
  258. method: 'POST',
  259. data: data,
  260. dataType: 'json',
  261. success: (res) => {
  262. //100成功
  263. if (res.data.Code == 100) {
  264. console.log("删除项目成功", res);
  265. _self.paging(_self.currentPage);
  266. }
  267. //200失败
  268. else {
  269. console.log('删除项目失败200', res);
  270. }
  271. uni.hideLoading();
  272. },
  273. fail: (res) => {
  274. console.log("删除项目失败");
  275. uni.hideLoading();
  276. }
  277. });
  278. }
  279. this.$refs.popAlert.setContent('是否删除项目',callback);
  280. }
  281. }
  282. }
  283. </script>
  284. <style lang="scss">
  285. @import '../../assets/icon/iconfont.css';
  286. .m_right {
  287. width: 100%;
  288. margin-top: 5rpx;
  289. padding: 0 150rpx;
  290. background-color: #fff;
  291. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  292. .m_right_hander {
  293. text-align: right;
  294. height: 250rpx;
  295. position: relative;
  296. .m_btn_red {
  297. position: absolute;
  298. height: 80rpx;
  299. line-height: 80rpx;
  300. padding: 0 40rpx;
  301. right: 0;
  302. top: 50%;
  303. transform: translateY(-50%);
  304. background: #EA252C;
  305. color: #fff;
  306. }
  307. }
  308. }
  309. tbody tr {
  310. // border-top: 2rpx solid #DDDDDD !important;
  311. border: 2rpx solid #DDDDDD !important;
  312. }
  313. th {
  314. border: 2rpx solid #DDDDDD !important;
  315. }
  316. tbody tr th {
  317. font-weight: 400 !important;
  318. height: 140rpx;
  319. line-height: 140rpx;
  320. }
  321. // tbody tr:hover {
  322. // // color: #fff;
  323. // background: #FDEBEC;
  324. // // opacity: 0.08;
  325. // }
  326. .m-table-hander {
  327. background-color: #FFF8F7;
  328. height: 140rpx;
  329. line-height: 140rpx;
  330. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  331. font-weight: bold;
  332. }
  333. .m_edit {
  334. // position: absolute;
  335. // top: 50%;
  336. // left: 50%;
  337. // transform: translate(-50%, -50%);
  338. background: rgb(67, 127, 250);
  339. color: rgb(255, 255, 255);
  340. // min-width: 130rpx;
  341. }
  342. .m_delete {
  343. // position: absolute;
  344. // top: 50%;
  345. // left: 50%;
  346. // min-width: 130rpx;
  347. // transform: translate(-50%, -50%);
  348. background: rgb(234, 37, 44);
  349. color: rgb(255, 255, 255);
  350. }
  351. .m_online {
  352. // background: #437FFA;
  353. // position: absolute;
  354. // top: 50%;
  355. // left: 50%;
  356. // min-width: 130rpx;
  357. // transform: translate(-50%, -50%);
  358. background: #437FFA;
  359. color: rgb(255, 255, 255);
  360. }
  361. .m_offline {
  362. background: #FD813B;
  363. position: absolute;
  364. top: 50%;
  365. left: 50%;
  366. min-width: 130rpx;
  367. transform: translate(-50%, -50%);
  368. color: rgb(255, 255, 255);
  369. }
  370. .m_right_footer {
  371. margin-top: 80rpx;
  372. }
  373. .m_paging {
  374. text-align: right;
  375. .m_paging_item {
  376. padding: 10rpx 18rpx;
  377. border: 1rpx solid #DDDDDD;
  378. border-radius: 8rpx;
  379. margin-right: 10rpx;
  380. }
  381. .p_act {
  382. background: #EA252C;
  383. color: #fff;
  384. border: inherit;
  385. }
  386. }
  387. .m_paging_item:hover {
  388. background: #EA252C;
  389. color: #fff;
  390. border: inherit;
  391. }
  392. .m_act1 {
  393. color: #FF0019;
  394. }
  395. </style>