mixin.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import { apiFlowDetail, apiSealAdd, apiSearchCustome, apiSearchContract,apiSearchAllCustome,getBelongCompany } from "@/api/approve/seal.js";
  2. import { uploadFiles } from "@/utils/uploadFile.js";
  3. import { preViewFile } from "../utils/util.js";
  4. export const sealMixin = {
  5. computed: {
  6. typeLength() {
  7. if (this.type.length > 0) {
  8. return true;
  9. } else {
  10. return false;
  11. }
  12. },
  13. },
  14. watch: {
  15. showCustome() {
  16. this.searchCustomeVal = "";
  17. this.searchCustomeStatus = true;
  18. this.searchCustomeList = [];
  19. this.searchContractList = [];
  20. },
  21. showType() {
  22. if (!this.showType) {
  23. this.temType = JSON.parse(JSON.stringify(this.type));
  24. }
  25. },
  26. },
  27. data() {
  28. return {
  29. showPurpose: false, //显示用印用途选项
  30. purposeArr: ["销售合同", "代付合同", "总对总协议", "渠道合同", "付款通知函", "招投标", "战略合作协议"],
  31. purpose: "",
  32. showType: false, //显示用印用途选项
  33. typeArr: ["合同章", "公章", "法人章","电子合同章"],
  34. type: [],
  35. temType: [], //临时存放选择的用印用途
  36. showServiceType: false, //显示业务类型选项
  37. ServiceTypeArr: ["新签合同", "续约合同", "补充协议",'代付合同'],
  38. ServiceType: "", //业务类型
  39. showCustome: false, //显示搜索客户名称
  40. customeName: "", //客户名称
  41. fileNum: "", //文件数
  42. remark: "", //备注
  43. CreditCode: "", //社会统一信用代码
  44. UseCompanyName: "", //实际使用方客户名称
  45. ContractId: 0, //合同id
  46. // file: {
  47. // type: "",
  48. // img: "",
  49. // url: "",
  50. // }, //上传附件 文件
  51. // 上传的附件列表 需求更改,可上传多个附件 crm-8.7
  52. fileList:[],
  53. processData: null, //流程数据
  54. radioVal: "系统合同",
  55. searchCustomeVal: "", //搜索客户输入数据
  56. searchCustomeStatus: true, //搜索客户 是否有结果
  57. searchCustomeList: [], //搜索到的客户名称列表
  58. searchContractList: [], //选择搜索中的客户后合同列表数据
  59. allCustome:{
  60. index:1,
  61. list:[],
  62. finished:false,
  63. loading:false
  64. },
  65. temCustomeName:'',
  66. //归属公司弹窗
  67. showBelongCompanyPop:false,
  68. belongCompany:'',
  69. belongCompanyOptions:[]
  70. };
  71. },
  72. methods: {
  73. async getBelongCompanyOptions() {
  74. const res = await getBelongCompany()
  75. if(res.code !==200 ) return
  76. this.belongCompanyOptions = res.data || []
  77. },
  78. //删除上传的附件
  79. handleDeleteCheckFile(file) {
  80. this.fileList = this.fileList.filter(item => item.url!= file.url)
  81. },
  82. //预览文件
  83. handlePreviewFiles(e) {
  84. if (e.type === "pdf" || e.type === "word") {
  85. preViewFile(e.url);
  86. } else {
  87. uni.previewImage({
  88. urls: [e.url],
  89. });
  90. }
  91. },
  92. //上传附件
  93. async handleUpload() {
  94. const res = await uploadFiles({ type: "all" });
  95. const reg = /\.(pdf)$/;
  96. const reg2 = /\.doc|\.docx$/;
  97. if (reg.test(res[0])) {
  98. this.fileList.push({
  99. type: "pdf",
  100. url: res[0],
  101. img: require("../static/pdf.png"),
  102. });
  103. } else if (reg2.test(res[0])) {
  104. this.fileList.push({
  105. type: "word",
  106. url: res[0],
  107. img: require("../static/word.png"),
  108. });
  109. } else {
  110. this.fileList.push({
  111. type: "img",
  112. url: res[0],
  113. img: res[0],
  114. });
  115. }
  116. },
  117. // 客户搜索
  118. // 先搜索出客户 再通过客户去请求出客户下面存在的合同
  119. onSearchValChange(e) {
  120. this.searchCustomeVal = e.detail;
  121. },
  122. //搜索客户
  123. async onSearch() {
  124. if (!this.searchCustomeVal) {
  125. uni.showToast({
  126. title: "请输入搜索关键字",
  127. icon: "none",
  128. });
  129. return;
  130. }
  131. this.searchContractList = [];
  132. this.searchCustomeList = [];
  133. const res = await apiSearchCustome({ Keyword: this.searchCustomeVal });
  134. if (res.code === 200) {
  135. this.searchCustomeList = res.data;
  136. if (res.data.length === 0) {
  137. this.searchCustomeStatus = false;
  138. } else {
  139. this.searchCustomeStatus = true;
  140. }
  141. }
  142. },
  143. // 搜索客户对应的合同
  144. async getContract(e) {
  145. const res = await apiSearchContract({ Keyword: e });
  146. if (res.code === 200) {
  147. if (res.data.List) {
  148. this.searchContractList = res.data.List;
  149. } else {
  150. uni.showToast({
  151. title: "此客户无合同,请重新选择",
  152. icon: "none",
  153. });
  154. }
  155. }
  156. },
  157. //归属公司选择
  158. handleComfirmBelongCmpany(e) {
  159. this.belongCompany = e.detail.value;
  160. this.showBelongCompanyPop = false;
  161. },
  162. // 选择用印用途
  163. handlePurposeConfirm(e) {
  164. this.purpose = e.detail.value;
  165. this.showPurpose = false;
  166. },
  167. //确认盖章类型
  168. handleTypeConfirm(e) {
  169. this.type = JSON.parse(JSON.stringify(this.temType));
  170. this.showType = false;
  171. this.getProcessData();
  172. },
  173. // 盖章类型变换
  174. onChangeType(e) {
  175. this.temType = e.detail;
  176. },
  177. //选择业务类型
  178. handleServiceTypeConfirm(e) {
  179. this.ServiceType = e.detail.value;
  180. this.showServiceType = false;
  181. },
  182. //合同章5 公章、法人章 6
  183. async getProcessData() {
  184. if(this.type.length===0) return
  185. let id = 0;
  186. if (this.type.includes("公章") || this.type.includes("法人章")) {
  187. id = 6;
  188. } else {
  189. id = 5;
  190. }
  191. let res = await apiFlowDetail({ FlowId: id });
  192. if (res.code === 200) {
  193. this.processData = res.data || null;
  194. }
  195. },
  196. handleAllCutomeInput(e){
  197. this.temCustomeName=e.detail.value
  198. this.allCustome.index=1
  199. this.allCustome.list=[]
  200. this.allCustome.finished=false
  201. this.allCustome.loading=false
  202. if(this.temCustomeName){
  203. this.getSearchAllCustome()
  204. }
  205. },
  206. // 搜素全部客户
  207. async getSearchAllCustome(){
  208. this.allCustome.loading=true
  209. const res=await apiSearchAllCustome({
  210. PageSize:20,
  211. CurrentIndex:this.allCustome.index,
  212. Keyword:this.temCustomeName,
  213. })
  214. this.allCustome.loading=false
  215. if(res.code===200){
  216. if(res.data){
  217. this.allCustome.list=[...this.allCustome.list,...res.data]
  218. }else{
  219. this.allCustome.finished=true
  220. }
  221. }
  222. },
  223. // 搜素全部客户弹窗触底
  224. handleScrollToLower(){
  225. if(this.allCustome.loading||this.allCustome.finished) return
  226. this.allCustome.index++
  227. this.getSearchAllCustome()
  228. },
  229. chooseAllCustomeItem(e){
  230. this.customeName=e.CompanyName
  231. this.allCustome.index=1
  232. this.allCustome.list=[]
  233. this.allCustome.finished=false
  234. this.allCustome.loading=false
  235. },
  236. // 收起搜索弹窗
  237. handleClickPage(){
  238. if(this.allCustome.list.length>0){
  239. this.allCustome.index=1
  240. this.allCustome.list=[]
  241. this.allCustome.finished=false
  242. this.allCustome.loading=false
  243. }
  244. },
  245. },
  246. };