| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- disabled: {
- type: Boolean,
- value: false
- }
- },
- options: {
- addGlobalClass: true
- },
- data: {
- sa_trialid: 0,
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 10,
- pageTotal: 1,
- total: null,
- where: {
- condition: ""
- }
- },
- list: [],
- showSearch: false,
- focus: false,
- condition: ""
- },
- methods: {
- getList(id, init = false) {
- let content = {
- ...this.data.content,
- sa_trialid: id || this.data.sa_trialid
- };
- if (init) {
- content.pageNumber = 1
- content.pageTotal = 1
- }
- _Http.basic({
- "id": 2025110715410702,
- 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_trialid: content.sa_trialid
- })
- })
- },
- /* 去添加产品 */
- addProduct() {
- let page = getCurrentPages().find(v => v.__route__ == 'prsx/tryOut/detail').data,
- detail = page.detail,
- query = "&newprice=contractprice"; /* marketprice */
- wx.navigateTo({
- url: `/prsx/select/product/index?params=${JSON.stringify({
- "id":2025110715184302,
- "content": {
- nocache:true,
- sa_trialid:detail.sa_trialid, //订单ID
- "total": 0,
- "where": {
- "condition": ""
- }
- }
- })+query}`
- });
- this.setData({
- type: detail.type
- })
- _Http.handleSelect = this.handleSelect.bind(this);
- },
- /* 处理新增产品 */
- handleSelect(detail) {
- console.log(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": 2025110715293102,
- "content": {
- ...that.data.base,
- sa_trialid:this.data.sa_trialid,
- "items": detail.list.map(v => {
- return {
- sa_trialitemsid: 0,
- "itemid": v.itemid, //商品ID
- "qty": 1, //数量
- remarks: v.remarks
- }
- })
- }
- }).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();
- that.updateThePrice();
- }, 300)
- })
- }
- });
- },
- deleteItem(e) {
- const {
- item
- } = e.currentTarget.dataset,
- that = this;
- wx.showModal({
- content: `是否确定删除该试用明细下的产品`,
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": "2025110715414702",
- "content": {
- sa_trialid: this.data.sa_trialid,
- sa_trialitemsids: [item.sa_trialitemsid]
- },
- }).then(res => {
- wx.showToast({
- title: res.code == 1 ? '删除成功' : res.msg,
- icon: "none"
- })
- if (res.code == 1) {
- that.getList('', true)
- }
- })
- }
- })
- },
- 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)
- },
- changeQty(e) {
- let value = e.detail.value,
- index = e.currentTarget.dataset.index;
- this.data.list[index].qty = value;
- _Http.basic({
- "id": 2025110715293102,
- "content": {
- "sa_trialid": this.data.sa_trialid,
- items: this.data.list
- }
- }).then(res => {
- console.log("修改数量", res)
- wx.showToast({
- title: res.code == 1 ? '修改成功' : res.msg,
- icon: "none"
- })
- // if (res.code == 1) getCurrentPages().find(v => v.__route__ == 'prsx/tyrOut/detail').getDetail()
- })
- },
- onChange({
- detail
- }) {
- this.data.condition = detail;
- },
- onSearch({
- detail
- }) {
- this.data.content.where.condition = detail;
- this.getList("", true)
- },
- }
- })
|