dk-list.js 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. /*******************************************************************************
  2. * Copyright(c) 2024 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:组件-列表
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 周兴 2024-1-30 1.00 新建
  9. *******************************************************************************/
  10. const config = require('@/config/config.js');
  11. const app = getApp();
  12. Component({
  13. /**
  14. * 组件的属性列表
  15. */
  16. properties: {
  17. // 数据源
  18. list: {
  19. type: Array,
  20. value: []
  21. },
  22. // 标题左侧角列名
  23. titleCorner: {
  24. type: String,
  25. },
  26. // 标题图标
  27. titleImage: {
  28. type: String,
  29. value: 'Vector.png'
  30. },
  31. customText:{
  32. type: String,
  33. value: ''
  34. },
  35. statusImageFlag: {
  36. //-作废 收款显示隐藏
  37. type: Boolean,
  38. value: false
  39. },
  40. // 图标-作废 收款
  41. statusImage: {
  42. type: String,
  43. value: 'cancel.png'
  44. },
  45. // 标题
  46. title: {
  47. type: String,
  48. },
  49. // 显示员工身份
  50. roleValue: {
  51. type: String,
  52. },
  53. // 状态
  54. status: {
  55. type: String,
  56. },
  57. // 是否显示功能三点
  58. flgPoint: {
  59. type: Boolean,
  60. value: true
  61. },
  62. flgValidOnFlag: { //默认显示启用
  63. type: Boolean,
  64. value: true
  65. },
  66. // 副标题
  67. subTitle: {
  68. type: String,
  69. },
  70. // 副标题(格式化日期)
  71. flgSubFormatDate: {
  72. type: Boolean,
  73. value: false
  74. },
  75. // 内容
  76. content: {
  77. type: Array,
  78. value: []
  79. },
  80. // 内容(不定)
  81. contentObj: {
  82. type: Object,
  83. },
  84. // 不定列的列名
  85. contentCol: {
  86. type: String,
  87. },
  88. // 底部信息
  89. footerInfo: {
  90. type: Array
  91. },
  92. // 底部金额
  93. footerAmount: {
  94. type: Object
  95. },
  96. // 底部tag的名称
  97. footerTag: {
  98. type: String,
  99. },
  100. // 按钮信息
  101. buttonList: {
  102. type: Array
  103. },
  104. // 页面路由
  105. routeObjName: {
  106. type: String
  107. },
  108. // 金额字段
  109. collectCol: {
  110. type: String
  111. },
  112. // 金额对应的描述字段
  113. collectName: {
  114. type: String
  115. },
  116. titleImageFlag: { //标题图片显示隐藏
  117. type: Boolean,
  118. value: true
  119. },
  120. // 是否显示选择框
  121. chooseFlag: { //标题图片显示隐藏
  122. type: Boolean,
  123. value: false
  124. },
  125. statusFlag: { //状态显示隐藏
  126. type: Boolean,
  127. value: true
  128. },
  129. switchFlag: { //启用停用状态
  130. type: Boolean,
  131. value: false
  132. },
  133. swipeDisabled: { //侧滑 默认禁用 false开启
  134. type: Boolean,
  135. value: true
  136. },
  137. // 是否侧滑删除 (删除,启用/停用)
  138. swipeDeleteFlag: {
  139. type: Boolean,
  140. value: false
  141. },
  142. subMainTitle: { //主标题右侧文本 value
  143. type: String
  144. },
  145. subMainTitlelabel: { //主标题右侧文本 label
  146. type: String
  147. },
  148. subTitle: {//主标题右侧文本
  149. type: String
  150. },
  151. defaultFlagKey: { //默认key
  152. type: String
  153. },
  154. defaultFlag: { //开启默认
  155. type: Boolean,
  156. value: false
  157. },
  158. simpleFlag: { // 简单模式
  159. type: Boolean,
  160. value: false
  161. },
  162. detailReportFlag: { // 明细报表标识
  163. type: Boolean,
  164. value: false
  165. },
  166. titleBtnText:{ // 标题栏按钮
  167. type:String,
  168. },
  169. statusImageFlag:{ //自定义图 是否开启
  170. type: Boolean,
  171. value: false
  172. },
  173. statusImageFlagValue:{ //自定义显示图片状态
  174. type:String,
  175. },
  176. },
  177. /**
  178. * 组件的初始数据
  179. */
  180. data: {
  181. imageUrl: config.image_url + '/static/img/',
  182. // 是否显示pop
  183. show: false,
  184. $t: app.globalData.lang,
  185. routeUrl: app.globalData['routeUrl'],
  186. item: null,
  187. },
  188. /**
  189. * 组件的方法列表
  190. */
  191. methods: {
  192. /**
  193. * @desc : 点击不再续费
  194. * @author : 周兴
  195. * @date : 2024/2/19 11:46
  196. */
  197. handleTitleBtn(e){
  198. this.triggerEvent("clickTitleBtn", { item: e.currentTarget.dataset.item })
  199. },
  200. /**
  201. * @desc : 选择数据
  202. * @author : 周兴
  203. * @date : 2024/2/19 11:46
  204. */
  205. chooseData(e) {
  206. let index = e.currentTarget.dataset.index
  207. this._chooseData(index);
  208. },
  209. /**
  210. * @desc : 选择数据(私有方法)
  211. * @author : 周兴
  212. * @date : 2024/2/19 11:46
  213. */
  214. _chooseData(index) {
  215. let list = this.data.list;
  216. if (list && list[index]) {
  217. list[index].checked = !list[index].checked
  218. }
  219. this.setData({
  220. list: list
  221. })
  222. // 勾选数据
  223. this.triggerEvent("choose", {
  224. item: list[index],
  225. index: index,
  226. list: list.filter(it => it.checked),
  227. checked: list[index].checked
  228. })
  229. },
  230. /**
  231. * @desc : 修改金额
  232. * @author : 周兴
  233. * @date : 2024/5/22 11:46
  234. */
  235. changeNumberInput(e) {
  236. let index = e.currentTarget.dataset.index
  237. let key = e.currentTarget.dataset.key
  238. let value = e.detail.value
  239. let list = this.data.list;
  240. if (list && list[index]) {
  241. list[index][key] = Number(value)
  242. }
  243. this.setData({
  244. list: list
  245. })
  246. this.triggerEvent("changeNumberInput", { key: key,value: value,
  247. index: e.currentTarget.dataset.index })
  248. },
  249. /**
  250. * @desc : 打电话
  251. * @author : 周兴
  252. * @date : 2024/2/19 11:46
  253. */
  254. openTelPhone(e) {
  255. let phoneFlag = false;
  256. let item = e.currentTarget.dataset.col;
  257. if (e.currentTarget.dataset.phone
  258. || (typeof item.name == 'string' && item.name.toLowerCase().indexOf('phone') >= 0)) {
  259. phoneFlag = true;
  260. }
  261. let tel = e.currentTarget.dataset.value
  262. if (phoneFlag && !tel) {
  263. phoneFlag = false;
  264. }
  265. // 拨打电话
  266. if (phoneFlag) {
  267. wx.makePhoneCall({
  268. phoneNumber: tel,
  269. })
  270. } else {
  271. // 跳转明细
  272. this.toDetail(e);
  273. }
  274. },
  275. /**
  276. * @desc : 跳转明细页面
  277. * @author : 周兴
  278. * @date : 2024/1/26 11:46
  279. */
  280. toDetail(e) {
  281. // 相当于勾选
  282. if (this.data.chooseFlag) {
  283. this.chooseData(e);
  284. } else {
  285. this.triggerEvent("toDetail", { item: e.currentTarget.dataset.item,
  286. index: e.currentTarget.dataset.index })
  287. }
  288. },
  289. /**
  290. * @desc : 跳转标题页面
  291. * @author : 周兴
  292. * @date : 2024/1/26 11:46
  293. */
  294. toTitle(e) {
  295. this.triggerEvent("toTitle", { item: e.currentTarget.dataset.item ,
  296. index: e.currentTarget.dataset.index })
  297. },
  298. /**
  299. * @desc : 跳转状态
  300. * @author : 周兴
  301. * @date : 2024/1/26 11:46
  302. */
  303. toStatus(e) {
  304. this.triggerEvent("toStatus", { item: e.currentTarget.dataset.item })
  305. },
  306. /**
  307. * @desc : 跳转三点事件
  308. * @author : 周兴
  309. * @date : 2024/1/26 11:46
  310. */
  311. toPoint(e) {
  312. this.triggerEvent("toPoint", { item: e.currentTarget.dataset.item })
  313. this.setData({
  314. show: true,
  315. item: e.currentTarget.dataset.item
  316. })
  317. },
  318. /**
  319. * @desc : 点击按钮
  320. * @author : 周兴
  321. * @date : 2024/1/26 11:46
  322. */
  323. clickButton(e) {
  324. let item = this.data.item;
  325. let button = e.currentTarget.dataset.item;
  326. let flag = true;
  327. // 如果需要弹出询问 todo
  328. // if(button.question){
  329. // setTimeout(()=>{
  330. // Dialog.confirm({
  331. // message: '是否进行该操作?',
  332. // }).then(() => {
  333. // flag = true;
  334. // }).catch(() => {
  335. // })
  336. // },200)
  337. // }else{
  338. // flag = true;
  339. // }
  340. // 点击询问后再往下进行
  341. if (flag) {
  342. item = Object.assign(item, { button: button })
  343. let obj = {
  344. item: item,
  345. name: e.currentTarget.dataset.item.name,
  346. url: e.currentTarget.dataset.item.url
  347. }
  348. this.triggerEvent("open", obj)
  349. this.setData({
  350. show: false
  351. })
  352. }
  353. },
  354. /**
  355. * @desc : 侧滑点击事件
  356. * @author : 于继渤
  357. * @date : 2024/1/26 11:46
  358. */
  359. onCloseSwipe(e) {
  360. const { position, instance } = e.detail;
  361. instance.close();
  362. let obj = {
  363. item: e.currentTarget.dataset.item,
  364. index: e.currentTarget.dataset.index
  365. }
  366. this.triggerEvent("swipe", obj)
  367. },
  368. /**
  369. * @desc : 关闭弹窗
  370. * @author : 周兴
  371. * @date : 2024/1/26 11:46
  372. */
  373. closePop() {
  374. this.setData({
  375. show: false
  376. })
  377. },
  378. }
  379. })