| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- disabled: {
- type: Boolean,
- value: false
- },
- sa_serviceorderid: {
- type: [String, Number]
- }
- },
- options: {
- addGlobalClass: true
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- this.setData({
- siteid: wx.getStorageSync('userMsg').siteid
- })
- }
- },
- data: {
- sa_workorderid: 0,
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 10,
- pageTotal: 1,
- total: null,
- where: {
- condition: ""
- }
- },
- list: [],
- showSearch: false,
- focus: false,
- condition: "",
- actionShow: false,
- actions: [{
- name: getApp().globalData.Language.getMapText('自服务申请单添加'),
- value: "自服务申请单添加",
- }, {
- name: getApp().globalData.Language.getMapText('自产品档案添加'),
- value: "自产品档案添加"
- }]
- },
- methods: {
- getList(id, init = false) {
- console.log("getList", id)
- let content = {
- ...this.data.content,
- sa_workorderid: id || this.data.sa_workorderid
- };
- if (init) {
- content.pageNumber = 1
- content.pageTotal = 1
- }
- _Http.basic({
- "id": 2026012813264502,
- content
- }).then(res => {
- console.log("服务产品", res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- let list = res.data.map(v => {
- try {
- v.cover = v.attinfos.length ? _Http.getSpecifiedImage(v.attinfos[0]) : ''
- } catch (error) {
- }
- return v
- })
- this.setData({
- "content.pageNumber": res.pageNumber + 1,
- "content.pageTotal": res.pageTotal,
- "content.total": res.total,
- list: res.pageNumber == 1 ? list : this.data.list.concat(list),
- sa_workorderid: content.sa_workorderid
- })
- })
- },
- onBlur(e) {
- let {
- value
- } = e.detail, {
- name,
- item,
- index
- } = e.currentTarget.dataset;
- if (item[name] == value) return;
- if (name == 'qty' && value <= 0) {
- getApp().globalData.Language.modeBoxPrompts('数量不符合规则,已重置为1')
- item[name] = 1
- } else {
- item[name] = value
- }
- _Http.basic({
- "id": "20230215201903",
- "content": {
- "sa_workorderid": this.data.sa_workorderid,
- "iteminfos": [item]
- }
- }).then(res => {
- console.log("产品修改", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setData({
- [`list[${index}]`]: item
- })
- });
- },
- toSearch() {
- if (this.data.showSearch && this.data.content.where.condition) {
- this.data.content.where.condition = '';
- this.getList("", true);
- } else if (this.data.condition) {
- this.data.content.where.condition = this.data.condition;
- this.setData({
- condition: this.data.condition
- })
- this.getList("", true);
- }
- this.setData({
- showSearch: !this.data.showSearch
- })
- setTimeout(() => {
- this.setData({
- focus: this.data.showSearch
- })
- }, 300)
- },
- deleteItem(e) {
- const {
- item
- } = e.currentTarget.dataset,
- that = this;
- wx.showModal({
- content: getApp().globalData.Language.getMapText(`是否确定删除该产品`),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": "20230215202003",
- "content": {
- "sa_workorder_node_itemsids": [item.sa_workorder_node_itemsid]
- },
- }).then(res => {
- wx.showToast({
- title: res.code == 1 ? getApp().globalData.Language.getMapText(`删除成功`) : res.msg,
- icon: "none"
- })
- if (res.code == 1) {
- that.getList('', true)
- }
- })
- }
- })
- },
- selectorMode(e) {
- let {
- value
- } = e.detail;
- wx.navigateTo({
- url: `/E-service/serviceBillList/product/select?params=${JSON.stringify({
- "content": {
- "sa_workorderid":this.data.sa_workorderid,
- "type": value == '自产品档案添加'?1:2,//1档案,2:申请单
- "pageNumber": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- }},
- "id": "2026022710102502",
- })}`
- });
- getApp().globalData.handleSelect = this.handleSelect.bind(this)
- this.cancelSelector()
- },
- /* 处理新增产品 */
- handleSelect(detail) {
- let that = this;
- wx.showModal({
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- v: '是否确认添加',
- t: 1
- }, {
- v: detail.result.length,
- t: 1,
- r: ' ',
- f: " "
- }, {
- v: '件商品',
- t: 1,
- r: '?',
- }]),
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": "20230215201903",
- "content": {
- "sa_workorder_nodeid": 0,
- sa_workorderid: this.data.sa_workorderid,
- "iteminfos": detail.list.map(v => {
- return {
- "sa_workorder_node_itemsid": 0,
- "problem_description": "",
- "processing": "",
- "result": "",
- "reason": "",
- "qty": 1,
- "itemid": v.itemid
- }
- })
- },
- }).then(s => {
- console.log('新增产品', s)
- wx.showToast({
- title: s.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : s.msg,
- icon: "none"
- });
- if (s.code == '1') setTimeout(() => {
- that.getList('', true);
- wx.navigateBack();
- }, 300)
- })
- }
- });
- },
- addProduct() {
- this.setData({
- actionShow: true
- })
- },
- cancelSelector() {
- this.setData({
- actionShow: false
- })
- },
- onChange({
- detail
- }) {
- this.data.condition = detail;
- },
- onSearch({
- detail
- }) {
- this.data.content.where.condition = detail;
- this.getList("", true)
- },
- }
- })
|