add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back"
  4. :title="this.form.id?'修改采购需求':'新建采购需求'" @clickLeft="back">
  5. </uni-nav-bar>
  6. <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
  7. <u-cell-group v-show='current==0'>
  8. <u-cell :title="'需求类型'" arrow-direction="down">
  9. <view slot="title" style="display: flex; align-items: center;">
  10. <text class="required-mark">*</text>
  11. 需求类型
  12. </view>
  13. <!-- <u--input slot="value" placeholder="请选择" border="surround" v-model="form.sourceType"
  14. @click.native="selectContactShow"></u--input> -->
  15. <!-- <u-picker :show="show" :columns="requirementSourceType" keyName="label"></u-picker> -->
  16. <uni-data-picker v-model="form.sourceType" slot="value" placeholder="请选择"
  17. :localdata="requirementSourceType" @change="sourceCodeOnchange">
  18. </uni-data-picker>
  19. </u-cell>
  20. <u-cell :title="'需求单名称'" arrow-direction="down">
  21. <view slot="title" style="display: flex; align-items: center;">
  22. <text class="required-mark">*</text>
  23. 需求单名称
  24. </view>
  25. <u--input slot="value" placeholder="请输入" border="surround" v-model="form.requirementName"></u--input>
  26. </u-cell>
  27. <u-cell :title="'需求部门'" arrow-direction="down">
  28. <view slot="title" style="display: flex; align-items: center;">
  29. <text class="required-mark">*</text>
  30. 需求部门
  31. </view>
  32. <!-- <u--input slot="value" placeholder="请输入" border="surround" v-model="form.requireDeptId"></u--input> -->
  33. <u--input slot="value" @click.native="classification" style="flex:1" border="surround"
  34. placeholder="请选择需求部门" v-model="form.requireDeptId">
  35. </u--input>
  36. </u-cell>
  37. <u-cell :title="'需求人'" arrow-direction="down">
  38. <view slot="title" style="display: flex; align-items: center;">
  39. <text class="required-mark">*</text>
  40. 需求人
  41. </view>
  42. <!-- <u--input slot="value" placeholder="请输入" border="requireUserId" v-model="form.name"></u--input> -->
  43. <u--input style="flex:1" border="surround" v-model="form.requireUserId"
  44. placeholder="请选择需求人" @click.native="openSelector">
  45. </u--input>
  46. </u-cell>
  47. <u-cell title="是否接受拆单" arrow-direction="down">
  48. <!-- <u--input slot="value" :disabled="true" placeholder="请输入" border="surround"
  49. v-model="form.responsibleName"></u--input> -->
  50. <!-- <u-radio-group
  51. v-model="form.acceptUnpack"
  52. placement="column"
  53. @change="groupChange"
  54. >
  55. <u-radio
  56. :customStyle="{marginBottom: '8px'}"
  57. v-for="(item, index) in radiolist1"
  58. :key="index"
  59. :label="item.name"
  60. :name="item.name"
  61. @change="radioChange"
  62. >
  63. </u-radio>
  64. </u-radio-group> -->
  65. </u-cell>
  66. <u-cell title="'用途" arrow-direction="down">
  67. <view slot="title" style="display: flex; align-items: center;">
  68. <text class="required-mark">*</text>
  69. 用途
  70. </view>
  71. <uni-data-picker v-model="form.useTo" slot="value" placeholder="请选择"
  72. :localdata="business_opport_code" @change="sourceCodeOnchange">
  73. </uni-data-picker>
  74. </u-cell>
  75. <u-cell title="附件" arrow-direction="down">
  76. <view slot="value" style="display: flex;align-items: center;width: 100%;">
  77. <fileMain v-model="form.fileId"></fileMain>
  78. </view>
  79. </u-cell>
  80. <u-cell title="备注" arrow-direction="down">
  81. <u--textarea slot="value" placeholder="请输入" border="surround" v-model="form.remark"></u--textarea>
  82. </u-cell>
  83. </u-cell-group>
  84. <view class="footerButton">
  85. <u-button type="default" text="返回" @click="back"></u-button>
  86. <u-button type="primary" @click="save" text="保存"></u-button>
  87. </view>
  88. <produceList ref="produceListRef" v-show="current==1" :isTemporary="true"></produceList>
  89. <!-- <businessList ref="businessListRef" v-show="current==2"></businessList> -->
  90. <!-- <personnelList ref="personnelListRef" :linkList="linkList" v-show="current==3"></personnelList> -->
  91. <ba-tree-picker ref="treePicker" key="verify" :multiple="false" @select-change="confirm" title="选择部门"
  92. :selectedData="selectedData" :localdata="classificationList" valueKey="id" textKey="name"
  93. childrenKey="children" />
  94. <search-select ref="selector" v-model="form.requireUserId" :data-list="executorList" title="选择使用人" @change="onClose">
  95. </search-select>
  96. <u-toast ref="uToast"></u-toast>
  97. </view>
  98. </template>
  99. <script>
  100. // file:///D:/中赢/aiot-app/pages/warehouse/enterHouse/selectEnterType.vue
  101. import {
  102. getByCode
  103. } from '@/api/pda/common.js'
  104. import {
  105. contactDetail,
  106. } from '@/api/saleManage/contact/index.js'
  107. import {
  108. businessopportunitySave,
  109. getDetail
  110. } from '@/api/saleManage/businessOpportunity/index.js'
  111. import searchSelect from '@/pages/salesServiceManagement/accessory/components/searchSelect.vue';
  112. import produceList from '../components/produceList.vue'
  113. // import businessList from './components/businessList.vue'
  114. // import personnelList from './components/personnelList.vue'
  115. import fileMain from "@/pages/doc/index.vue"
  116. import { requirementSourceType } from '@/enum/dict'
  117. import {
  118. listOrganizations
  119. } from '@/api/salesServiceManagement/workOrder/index.js';
  120. import {
  121. toTreeData
  122. } from '@/utils/utils.js';
  123. import {
  124. getUserPage
  125. } from '@/api/common.js';
  126. export default {
  127. components: {
  128. produceList,
  129. // businessList,
  130. // personnelList,
  131. fileMain,
  132. searchSelect
  133. },
  134. data() {
  135. return {
  136. list: ['基本信息', '需求清单'],
  137. current: 0,
  138. show: false,
  139. requirementSourceType,
  140. classificationList: [],
  141. form: {
  142. id: '',
  143. receiveDate: null,
  144. remark: null,
  145. requireDeptId: '',
  146. requireDeptName: '',
  147. requireUserId: '',
  148. requireUserName: '',
  149. sourceCode: '',
  150. sourceId: '',
  151. sourceType: '',
  152. requirementName: '',
  153. saleContractName: '',
  154. saleContractNo: '',
  155. saleContractId: '',
  156. saleOrderId: '',
  157. saleOrderNo: '',
  158. files: [],
  159. acceptUnpack: 1,
  160. fileId: [] //附件集合
  161. },
  162. business_opport_code: [],
  163. linkList: [],
  164. selectedData: [], // 使用部门绑定值
  165. executorList: []
  166. }
  167. },
  168. created() {
  169. this.getByCode()
  170. },
  171. onLoad(data) {
  172. this.getTreeList()
  173. uni.$off('setSelectList')
  174. uni.$on('setSelectList', async (data) => {
  175. if (data && data.length > 0) {
  176. const {
  177. linkList
  178. } = await contactDetail(data[0].id)
  179. this.linkList = linkList
  180. this.$set(this.form, 'contactId', data[0].id);
  181. this.$set(this.form, 'contactName', data[0].name);
  182. }
  183. })
  184. if (data && data.id) {
  185. getDetail(data.id).then(async res => {
  186. this.form = res
  187. const {
  188. linkList
  189. } = await contactDetail(res.contactId)
  190. this.linkList = linkList
  191. this.$nextTick(() => {
  192. this.$refs.produceListRef.init(res.productList)
  193. this.$refs.businessListRef.init(res.competAnalysisList)
  194. this.$refs.personnelListRef.init(res.partyList)
  195. })
  196. })
  197. } else {
  198. const userInfo = uni.getStorageSync('userInfo')
  199. this.$set(this.form, 'responsibleId', userInfo.userId);
  200. this.$set(this.form, 'responsibleName', userInfo.name);
  201. }
  202. },
  203. onUnload() {
  204. uni.$off('setSelectList')
  205. // uni.$off('updatelinkList')
  206. },
  207. methods: {
  208. async getTreeList() {
  209. const data = await listOrganizations({});
  210. let treeList = toTreeData({
  211. data: data || [],
  212. idField: 'id',
  213. parentIdField: 'parentId'
  214. });
  215. this.classificationList = treeList;
  216. },
  217. // 打开部门弹窗
  218. classification() {
  219. this.$refs.treePicker._show();
  220. },
  221. // 使用部门选择
  222. confirm(id, name) {
  223. this.form.useDeptName = name;
  224. this.form.useDeptId = id[0];
  225. this.form.userId = '';
  226. this.form.userName = '';
  227. this.executorList = [];
  228. this.getUserList(id[0]);
  229. this.$refs.selector.clearSearchText();
  230. },
  231. // 打开使用人弹窗
  232. openSelector() {
  233. this.$refs.selector.open();
  234. },
  235. // 获取使用人数据
  236. async getUserList(id) {
  237. let params = {
  238. pageNum: 1,
  239. size: -1,
  240. groupId: id
  241. }
  242. try {
  243. const res = await getUserPage(params);
  244. let list = res.list && res.list.map((el) => {
  245. return {
  246. text: el.name,
  247. value: el.id
  248. }
  249. })
  250. this.executorList = list;
  251. } catch (error) {
  252. this.executorList = [];
  253. }
  254. },
  255. // 使用人选择
  256. onClose(item) {
  257. this.form.userName = item.text;
  258. },
  259. getByCode() {
  260. const codeS = ['business_opport_code']
  261. codeS.forEach(async (code) => {
  262. const codeValue = await getByCode(code);
  263. this[code] = codeValue.map(item => {
  264. const key = Object.keys(item)[0]
  265. return {
  266. value: key,
  267. text: item[key]
  268. }
  269. })
  270. })
  271. },
  272. selectContactShow() {
  273. uni.navigateTo({
  274. url: '/pages/saleManage/components/selectContact?isAll=' + 2
  275. })
  276. },
  277. sourceCodeOnchange(e) {
  278. const value = e.detail.value
  279. this.form.sourceCode = value.map(item => item.value).toString()
  280. this.form.sourceName = value.map(item => item.text).toString()
  281. },
  282. radioChange(e) {
  283. this.form.pricingWay = e.detail.value
  284. this.$nextTick(() => {
  285. this.$refs.produceListRef.getTotalPrice()
  286. })
  287. },
  288. sectionChange(index) {
  289. this.current = index;
  290. },
  291. async save() {
  292. try {
  293. if (!this.form.contactName) {
  294. this.$refs.uToast.show({
  295. type: "error",
  296. message: "请选择客户",
  297. })
  298. return
  299. }
  300. if (!this.form.name) {
  301. this.$refs.uToast.show({
  302. type: "error",
  303. message: "请输入商机名称",
  304. })
  305. return
  306. }
  307. if (!this.form.sourceCode) {
  308. this.$refs.uToast.show({
  309. type: "error",
  310. message: "请选择商机来源",
  311. })
  312. return
  313. }
  314. if (this.$refs.produceListRef.getValue().length == 0) {
  315. this.$refs.uToast.show({
  316. type: "error",
  317. message: "产品清单不能为空",
  318. })
  319. return;
  320. }
  321. uni.showLoading({
  322. title: '加载中'
  323. })
  324. const data = {
  325. opportunity: this.form,
  326. competAnalysisList: this.$refs.businessListRef.getValue(),
  327. partyList: this.$refs.personnelListRef.getValue(),
  328. productList: this.$refs.produceListRef.getValue()
  329. };
  330. businessopportunitySave(data)
  331. .then((id) => {
  332. uni.hideLoading()
  333. this.back()
  334. })
  335. .catch((e) => {
  336. uni.hideLoading()
  337. });
  338. } catch (error) {
  339. uni.hideLoading()
  340. console.log(error, 'error')
  341. }
  342. },
  343. }
  344. }
  345. </script>
  346. <style lang="scss" scoped>
  347. .required-mark {
  348. color: #FF3333;
  349. margin-right: 4rpx;
  350. }
  351. /deep/.u-cell__body__content {
  352. flex: none;
  353. margin-right: 16rpx;
  354. }
  355. .mainBox {
  356. padding-bottom: 84rpx;
  357. }
  358. .footerButton {
  359. width: 100%;
  360. height: 84rpx;
  361. display: flex;
  362. position: fixed;
  363. bottom: 0;
  364. z-index: 10;
  365. background-color: #fff;
  366. /deep/.u-button {
  367. height: 100%;
  368. }
  369. >view {
  370. flex: 1;
  371. }
  372. }
  373. /deep/.u-button {
  374. // height: 100%;
  375. }
  376. /deep/.u-subsection__item__text {
  377. font-size: 28rpx !important;
  378. }
  379. /deep/.uni-input-placeholder {
  380. font-size: 28rpx !important;
  381. }
  382. /deep/.selected-item {
  383. font-size: 28rpx !important;
  384. }
  385. /deep/.uni-input-input {
  386. font-size: 28rpx !important;
  387. }
  388. </style>