index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. disabled: {
  5. type: Boolean,
  6. value: false
  7. },
  8. sa_serviceorderid: {
  9. type: [String, Number]
  10. }
  11. },
  12. options: {
  13. addGlobalClass: true
  14. },
  15. lifetimes: {
  16. attached: function () {
  17. getApp().globalData.Language.getLanguagePackage(this)
  18. this.setData({
  19. siteid: wx.getStorageSync('userMsg').siteid
  20. })
  21. }
  22. },
  23. data: {
  24. sa_workorderid: 0,
  25. content: {
  26. nocache: true,
  27. pageNumber: 1,
  28. pageSize: 10,
  29. pageTotal: 1,
  30. total: null,
  31. where: {
  32. condition: ""
  33. }
  34. },
  35. list: [],
  36. showSearch: false,
  37. focus: false,
  38. condition: "",
  39. actionShow: false,
  40. actions: [{
  41. name: getApp().globalData.Language.getMapText('自服务申请单添加'),
  42. value: "自服务申请单添加",
  43. }, {
  44. name: getApp().globalData.Language.getMapText('自产品档案添加'),
  45. value: "自产品档案添加"
  46. }]
  47. },
  48. methods: {
  49. getList(id, init = false) {
  50. console.log("getList", id)
  51. let content = {
  52. ...this.data.content,
  53. sa_workorderid: id || this.data.sa_workorderid
  54. };
  55. if (init) {
  56. content.pageNumber = 1
  57. content.pageTotal = 1
  58. }
  59. _Http.basic({
  60. "id": 2026012813264502,
  61. content
  62. }).then(res => {
  63. console.log("服务产品", res)
  64. if (res.code != '1') return wx.showToast({
  65. title: res.data,
  66. icon: "none"
  67. });
  68. let list = res.data.map(v => {
  69. try {
  70. v.cover = v.attinfos.length ? _Http.getSpecifiedImage(v.attinfos[0]) : ''
  71. } catch (error) {
  72. }
  73. return v
  74. })
  75. this.setData({
  76. "content.pageNumber": res.pageNumber + 1,
  77. "content.pageTotal": res.pageTotal,
  78. "content.total": res.total,
  79. list: res.pageNumber == 1 ? list : this.data.list.concat(list),
  80. sa_workorderid: content.sa_workorderid
  81. })
  82. })
  83. },
  84. onBlur(e) {
  85. let {
  86. value
  87. } = e.detail, {
  88. name,
  89. item,
  90. index
  91. } = e.currentTarget.dataset;
  92. if (item[name] == value) return;
  93. if (name == 'qty' && value <= 0) {
  94. getApp().globalData.Language.modeBoxPrompts('数量不符合规则,已重置为1')
  95. item[name] = 1
  96. } else {
  97. item[name] = value
  98. }
  99. _Http.basic({
  100. "id": "20230215201903",
  101. "content": {
  102. "sa_workorderid": this.data.sa_workorderid,
  103. "iteminfos": [item]
  104. }
  105. }).then(res => {
  106. console.log("产品修改", res)
  107. if (res.code != '1') return wx.showToast({
  108. title: res.msg,
  109. icon: "none"
  110. });
  111. this.setData({
  112. [`list[${index}]`]: item
  113. })
  114. });
  115. },
  116. toSearch() {
  117. if (this.data.showSearch && this.data.content.where.condition) {
  118. this.data.content.where.condition = '';
  119. this.getList("", true);
  120. } else if (this.data.condition) {
  121. this.data.content.where.condition = this.data.condition;
  122. this.setData({
  123. condition: this.data.condition
  124. })
  125. this.getList("", true);
  126. }
  127. this.setData({
  128. showSearch: !this.data.showSearch
  129. })
  130. setTimeout(() => {
  131. this.setData({
  132. focus: this.data.showSearch
  133. })
  134. }, 300)
  135. },
  136. deleteItem(e) {
  137. const {
  138. item
  139. } = e.currentTarget.dataset,
  140. that = this;
  141. wx.showModal({
  142. content: getApp().globalData.Language.getMapText(`是否确定删除该产品`),
  143. complete: ({
  144. confirm
  145. }) => {
  146. if (confirm) _Http.basic({
  147. "id": "20230215202003",
  148. "content": {
  149. "sa_workorder_node_itemsids": [item.sa_workorder_node_itemsid]
  150. },
  151. }).then(res => {
  152. wx.showToast({
  153. title: res.code == 1 ? getApp().globalData.Language.getMapText(`删除成功`) : res.msg,
  154. icon: "none"
  155. })
  156. if (res.code == 1) {
  157. that.getList('', true)
  158. }
  159. })
  160. }
  161. })
  162. },
  163. selectorMode(e) {
  164. let {
  165. value
  166. } = e.detail;
  167. wx.navigateTo({
  168. url: `/E-service/serviceBillList/product/select?params=${JSON.stringify({
  169. "content": {
  170. "sa_workorderid":this.data.sa_workorderid,
  171. "type": value == '自产品档案添加'?1:2,//1档案,2:申请单
  172. "pageNumber": 1,
  173. "pageSize": 20,
  174. "where": {
  175. "condition": ""
  176. }},
  177. "id": "2026022710102502",
  178. })}`
  179. });
  180. getApp().globalData.handleSelect = this.handleSelect.bind(this)
  181. this.cancelSelector()
  182. },
  183. /* 处理新增产品 */
  184. handleSelect(detail) {
  185. let that = this;
  186. wx.showModal({
  187. cancelText: getApp().globalData.Language.getMapText('取消'),
  188. confirmText: getApp().globalData.Language.getMapText('确定'),
  189. title: getApp().globalData.Language.getMapText('提示'),
  190. content: getApp().globalData.Language.joint([{
  191. v: '是否确认添加',
  192. t: 1
  193. }, {
  194. v: detail.result.length,
  195. t: 1,
  196. r: ' ',
  197. f: " "
  198. }, {
  199. v: '件商品',
  200. t: 1,
  201. r: '?',
  202. }]),
  203. complete: (res) => {
  204. if (res.confirm) _Http.basic({
  205. "id": "20230215201903",
  206. "content": {
  207. "sa_workorder_nodeid": 0,
  208. sa_workorderid: this.data.sa_workorderid,
  209. "iteminfos": detail.list.map(v => {
  210. return {
  211. "sa_workorder_node_itemsid": 0,
  212. "problem_description": "",
  213. "processing": "",
  214. "result": "",
  215. "reason": "",
  216. "qty": 1,
  217. "itemid": v.itemid
  218. }
  219. })
  220. },
  221. }).then(s => {
  222. console.log('新增产品', s)
  223. wx.showToast({
  224. title: s.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : s.msg,
  225. icon: "none"
  226. });
  227. if (s.code == '1') setTimeout(() => {
  228. that.getList('', true);
  229. wx.navigateBack();
  230. }, 300)
  231. })
  232. }
  233. });
  234. },
  235. addProduct() {
  236. this.setData({
  237. actionShow: true
  238. })
  239. },
  240. cancelSelector() {
  241. this.setData({
  242. actionShow: false
  243. })
  244. },
  245. onChange({
  246. detail
  247. }) {
  248. this.data.condition = detail;
  249. },
  250. onSearch({
  251. detail
  252. }) {
  253. this.data.content.where.condition = detail;
  254. this.getList("", true)
  255. },
  256. }
  257. })