assets.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <view class="m_right">
  3. <view class="m_right_hander">
  4. <!-- <button size="mini" class="m_btn_red" @click="addZc()">添加资产</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>资产预览图</th>
  11. <th>资产名称</th>
  12. <th>上传人</th>
  13. <th>上传时间</th>
  14. <th>删除</th>
  15. </tr>
  16. </thead>
  17. <tbody>
  18. <tr v-for="(dataUser,dataUserI) in dataUsers_all" :key="dataUserI">
  19. <th>
  20. <image class="m_logoimg" :src="dataUser.Texture_Url" mode=""></image>
  21. </th>
  22. <th>{{dataUser.Name}}</th>
  23. <th>{{dataUser.CreateUserName}}</th>
  24. <th>{{dataUser.UploadTime}}</th>
  25. <th style="position: relative;"><button type="default" size="mini" class="m_delete" @click="deleteZc(dataUser)">删除</button></th>
  26. </tr>
  27. </tbody>
  28. </table>
  29. </view>
  30. <view class="m_right_footer">
  31. <view class="m_paging">
  32. <text class="m_paging_item m_paging_upper" v-show="bShowLastPageBtn" @click="last()">上一页</text>
  33. <text class="m_paging_item" v-for="i in pageTotalNum" @click="paging(i)" :key="i" :class="i==currentPage?'p_act':''">
  34. {{i}}
  35. </text>
  36. <text class="m_paging_item m_paging_lower" v-show="bShowNextPageBtn" @click="paging(i)">下一页</text>
  37. </view>
  38. </view>
  39. <popForm ref="popForm"></popForm>
  40. <popAlert ref="popAlert"></popAlert>
  41. </view>
  42. </template>
  43. <script>
  44. import popForm from '@/components/popForm.vue'
  45. import popAlert from '@/components/popAlert.vue'
  46. export default {
  47. name: "manager_assets",
  48. components: {
  49. popForm,
  50. popAlert,
  51. },
  52. data() {
  53. return {
  54. pageTotalNum:1,
  55. currentPage:1,
  56. totalItem:8,
  57. dataUsers_all: [],
  58. bShowLastPageBtn:false,
  59. bShowNextPageBtn:false,
  60. }
  61. },
  62. methods: {
  63. paging(i) {
  64. uni.showLoading({
  65. title: '加载中'
  66. });
  67. let fromIndex = this.totalItem*(i-1);
  68. let toIndex = fromIndex+this.totalItem;
  69. let data = {
  70. "UserID": mydata_userInfo.userID,
  71. "BeginNum": fromIndex, //用户数组索引
  72. "EndNum": toIndex, //用户数组索引结束
  73. "ItemType":""//道具 角色 场景 空为全部
  74. }
  75. uni.request({
  76. header: {
  77. 'Content-Type': 'application/json;charset=UTF-8'
  78. },
  79. url: mydata_api + '/item/getitemlist',
  80. method: 'POST',
  81. data: data,
  82. dataType: 'json',
  83. success: (res) => {
  84. //100成功
  85. if (res.data.Code == 100) {
  86. console.log("请求全部资产", res);
  87. this.dataUsers_all = res.data.Items;
  88. this.pageTotalNum = Math.ceil(res.data.AllOfItem/this.totalItem);
  89. this.currentPage = i;
  90. this.showNextOrLastPageBtn();
  91. }
  92. //200失败
  93. else {
  94. console.log('suc200', res);
  95. }
  96. uni.hideLoading();
  97. },
  98. fail: (res) => {
  99. console.log("请求失败****");
  100. uni.hideLoading();
  101. }
  102. });
  103. },
  104. initPage() {
  105. this.paging(1);
  106. },
  107. last()
  108. {
  109. this.currentPage--;
  110. this.paging(this.currentPage);
  111. },
  112. next()
  113. {
  114. this.currentPage++;
  115. this.paging(this.currentPage);
  116. },
  117. showNextOrLastPageBtn()
  118. {
  119. if(this.pageTotalNum==this.currentPage)
  120. {
  121. this.bShowLastPageBtn = true;
  122. this.bShowNextPageBtn = false;
  123. // console.log('11111')
  124. }
  125. else if(1==this.currentPage)
  126. {
  127. this.bShowLastPageBtn = false;
  128. this.bShowNextPageBtn = true;
  129. // console.log('2222')
  130. }
  131. else
  132. {
  133. this.bShowLastPageBtn = true;
  134. this.bShowNextPageBtn = true;
  135. // console.log('333333')
  136. }
  137. if(this.pageTotalNum==1){
  138. this.bShowLastPageBtn = false;
  139. this.bShowNextPageBtn = false;
  140. // console.log('444444')
  141. }
  142. },
  143. addZc(){
  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. "UserID":mydata_userInfo.userID,
  155. "ItemName":content_arr[0].input,
  156. }
  157. console.log('data===',data)
  158. uni.showLoading({
  159. title: '上传中'
  160. });
  161. uni.uploadFile({
  162. url: mydata_api + '/item/uploadfile',
  163. filePath: tempFilePaths[0],
  164. name: 'file',
  165. formData:data,
  166. success: (uploadFileRes) => {
  167. console.log("上传资产成功", uploadFileRes);
  168. _self.paging(_self.currentPage);
  169. uni.hideLoading();
  170. },
  171. fail: (res) => {
  172. console.log("上传失败");
  173. uni.hideLoading();
  174. }
  175. });
  176. };
  177. this.$refs.popForm.setContent([
  178. {
  179. 'name':'物品名称',
  180. 'input':'',
  181. 'type' :'text'
  182. }
  183. ],callback);
  184. }
  185. });
  186. },
  187. deleteZc(dataUser)
  188. {
  189. this.$refs.popAlert.isShow(true);
  190. this.$refs.popAlert.setTitle('提示');
  191. let _self = this;
  192. let callback = function(){
  193. let data = {
  194. "UserID":mydata_userInfo.userID,
  195. "ItemID":[dataUser.Id]
  196. }
  197. uni.showLoading({
  198. title: '删除中'
  199. });
  200. uni.request({
  201. header: {
  202. 'Content-Type': 'application/json;charset=UTF-8'
  203. },
  204. url: mydata_api + '/backstage/deleteitem',
  205. method: 'POST',
  206. data: data,
  207. dataType: 'json',
  208. success: (res) => {
  209. //100成功
  210. if (res.data.Code == 100) {
  211. console.log("删除资产成功", res);
  212. _self.paging(_self.currentPage);
  213. }
  214. //200失败
  215. else {
  216. console.log('删除用户资产失败200', res);
  217. }
  218. uni.hideLoading();
  219. },
  220. fail: (res) => {
  221. console.log("删除用户资产失败");
  222. uni.hideLoading();
  223. }
  224. });
  225. }
  226. this.$refs.popAlert.setContent('是否删除资产',callback);
  227. },
  228. }
  229. }
  230. </script>
  231. <style lang="scss">
  232. // 允许文字被选择
  233. th
  234. {
  235. moz-user-select: -moz-text;
  236. -moz-user-select: text;
  237. -o-user-select: text;
  238. -khtml-user-select: text;
  239. -webkit-user-select: text;
  240. -ms-user-select: text;
  241. user-select: text;
  242. }
  243. .m_right {
  244. width: 100%;
  245. margin-top: 5rpx;
  246. padding: 0 150rpx;
  247. background-color: #fff;
  248. box-shadow: 3px 0px 6px 0px rgba(0, 0, 0, 0.1);
  249. .m_right_hander {
  250. text-align: right;
  251. height: 250rpx;
  252. position: relative;
  253. .m_btn_red {
  254. position: absolute;
  255. height: 80rpx;
  256. line-height: 80rpx;
  257. padding: 0 40rpx;
  258. right: 0;
  259. top: 50%;
  260. transform: translateY(-50%);
  261. background: #EA252C;
  262. color: #fff;
  263. }
  264. }
  265. }
  266. tbody tr {
  267. // border-top: 2rpx solid #DDDDDD !important;
  268. border: 2rpx solid #DDDDDD !important;
  269. }
  270. th {
  271. border: 2rpx solid #DDDDDD !important;
  272. }
  273. tbody tr th:first-child {
  274. position: relative;
  275. }
  276. tbody tr th {
  277. font-weight: 400 !important;
  278. height: 140rpx;
  279. line-height: 140rpx;
  280. }
  281. // tbody tr:hover {
  282. // // color: #fff;
  283. // background: #FDEBEC;
  284. // // opacity: 0.08;
  285. // }
  286. .m-table-hander {
  287. background-color: #FFF8F7;
  288. height: 140rpx;
  289. line-height: 140rpx;
  290. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  291. font-weight: bold;
  292. }
  293. .m_edit {
  294. position: absolute;
  295. top: 50%;
  296. left: 50%;
  297. transform: translate(-50%, -50%);
  298. background: rgb(67, 127, 250);
  299. color: rgb(255, 255, 255);
  300. min-width: 130rpx;
  301. }
  302. .m_delete {
  303. // position: absolute;
  304. // top: 50%;
  305. // left: 50%;
  306. // min-width: 130rpx;
  307. // transform: translate(-50%, -50%);
  308. // background: rgb(234, 37, 44);
  309. // color: rgb(255, 255, 255);
  310. background: rgb(234, 37, 44);
  311. color: rgb(255, 255, 255);
  312. }
  313. .m_right_footer {
  314. margin-top: 80rpx;
  315. }
  316. .m_logoimg {
  317. width: 80rpx;
  318. height: 80rpx;
  319. position: absolute;
  320. top: 50%;
  321. left: 50%;
  322. transform: translate(-50%,-50%);
  323. }
  324. .m_paging {
  325. text-align: right;
  326. .m_paging_item {
  327. padding: 10rpx 18rpx;
  328. border: 1rpx solid #DDDDDD;
  329. border-radius: 8rpx;
  330. margin-right: 10rpx;
  331. }
  332. .p_act {
  333. background: #EA252C;
  334. color: #fff;
  335. border: inherit;
  336. }
  337. }
  338. .m_paging_item:hover {
  339. background: #EA252C;
  340. color: #fff;
  341. border: inherit;
  342. }
  343. .m_act1 {
  344. color: #FF0019;
  345. }
  346. </style>