add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <div>
  3. <!-- <el-dropdown size="small" split-button type="primary" @command="handleCommand">
  4. 新 建
  5. <el-dropdown-menu slot="dropdown">
  6. <el-dropdown-item command="标准订单">标准订单</el-dropdown-item>
  7. <el-dropdown-item command="项目订单">项目订单</el-dropdown-item>
  8. <el-dropdown-item command="促销订单">促销订单</el-dropdown-item>
  9. <el-dropdown-item command="工具订单">工具订单</el-dropdown-item>
  10. </el-dropdown-menu>
  11. </el-dropdown> -->
  12. <el-dropdown @command="handleCommand">
  13. <el-button type="primary" size="small">
  14. 新 建<i class="el-icon-arrow-down el-icon--right"></i>
  15. </el-button>
  16. <el-dropdown-menu slot="dropdown">
  17. <el-dropdown-item command="标准订单">标准订单</el-dropdown-item>
  18. <el-dropdown-item command="项目订单">项目订单</el-dropdown-item>
  19. <!-- <el-dropdown-item command="促销订单">促销订单</el-dropdown-item> -->
  20. <el-dropdown-item command="工具订单">工具订单</el-dropdown-item>
  21. <!-- <el-dropdown-item command="样品订单" v-if="siteId=='HY'">样品订单</el-dropdown-item> -->
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. <el-drawer
  25. title="新建订单"
  26. :visible.sync="drawer"
  27. direction="rtl"
  28. :show-close="false"
  29. append-to-body
  30. size="800px"
  31. @close="refresh">
  32. <div class="drawer__panel">
  33. <el-row :gutter="15">
  34. <el-form size="small" ref="form" :model="form" :rules="rules" label-width="100px" :status-icon="false">
  35. <el-col :span="24">
  36. <el-form-item label="订单类型" prop="type">
  37. <el-input readonly v-model="form.type" placeholder="订单类型" :maxlength="11" clearable :style="{width: '100%'}"></el-input>
  38. </el-form-item>
  39. </el-col>
  40. <el-col v-if="form.type === '促销订单'" :span="12">
  41. <el-form-item label="活动信息" prop="promname">
  42. <el-popover
  43. placement="bottom"
  44. trigger="click"
  45. v-model="visible1">
  46. <orderCanUseActivity ref="activity" @rowClick="activityClick"></orderCanUseActivity>
  47. <el-input readonly v-model="form.promname" slot="reference" placeholder="选择活动"></el-input>
  48. </el-popover>
  49. </el-form-item>
  50. </el-col>
  51. <el-col v-if="form.type === '项目订单'" :span="12">
  52. <el-form-item label="项目合同" prop="contractname">
  53. <el-popover
  54. placement="bottom"
  55. trigger="click"
  56. v-model="visible">
  57. <orderCanUseContract @rowClick="contractClick"></orderCanUseContract>
  58. <el-input readonly v-model="form.contractname" slot="reference" placeholder="选择合同"></el-input>
  59. </el-popover>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="12" v-if="form.type !=='工具订单' && form.type !=='项目订单'">
  63. <el-form-item label="选择品牌" prop="sa_brandid">
  64. <el-select :disabled="form.type === '促销订单'" v-model="form.sa_brandid" placeholder="请选择选择品牌" clearable :style="{width: '100%'}">
  65. <el-option v-for="(item, index) in sa_brandidOptions" :key="index" :label="item.brandname"
  66. :value="item.sa_brandid" :disabled="item.disabled"></el-option>
  67. </el-select>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="12" v-if="form.type !=='工具订单' && form.type !=='项目订单'">
  71. <el-form-item label="选择领域" prop="tradefield">
  72. <el-select :disabled="form.type === '促销订单'" v-model="form.tradefield" placeholder="请选择选择领域" clearable :style="{width: '100%'}">
  73. <el-option v-for="(item, index) in tradefieldOptions" :key="index" :label="item.tradefield"
  74. :value="item.tradefield" :disabled="item.disabled"></el-option>
  75. </el-select>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="12" v-if="form.type =='标准订单' || form.type =='项目订单'">
  79. <el-form-item label="是否样品订单" prop="typemx">
  80. <el-radio-group v-model="form.typemx">
  81. <el-radio label="样品">是</el-radio>
  82. <el-radio label="">否</el-radio>
  83. </el-radio-group>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="24" v-if="form.type ==='标准订单' || form.type ==='特殊订单' || form.type ==='样品订单'">
  87. <el-form-item label="项目备注">
  88. <el-input size="mini" class="order__note__input" type="textarea" v-model="form.projectnote" :autosize="{minRows:5}" placeholder="请输入项目备注"></el-input>
  89. </el-form-item>
  90. </el-col>
  91. </el-form>
  92. </el-row>
  93. </div>
  94. <div class="fixed__btn__panel">
  95. <el-button class="normal-btn-width" type="primary" size="small" @click="submitForm">创 建</el-button>
  96. <el-button class="normal-btn-width" size="small" @click="resetForm">重 置</el-button>
  97. </div>
  98. </el-drawer>
  99. </div>
  100. </template>
  101. <script>
  102. import enterprise from '@/template/enterprise/index.vue'
  103. import orderCanUseContract from '@/template/orderCanUseContract/index.vue'
  104. import orderCanUseActivity from '@/template/orderCanUseActivity/index.vue'
  105. export default {
  106. data () {
  107. return {
  108. drawer:false,
  109. visible:false,
  110. visible1:false,
  111. siteId:JSON.parse(sessionStorage.getItem('active_account')).siteid,
  112. form:{
  113. "sa_orderid": 0,
  114. "sa_accountclassid": 0, //营销账户类型ID
  115. "sa_brandid": "", //品牌ID
  116. "sa_contractid": 0, //合同ID,标准订单不传
  117. "sa_projectid": 0, //工程项目表ID,标准订单不传
  118. "sys_enterprise_financeid": 0, //合作企业财务信息ID(开票信息)
  119. "sa_logiscompid": 0, //物流公司档案ID
  120. "rec_contactsid": 0, //合作企业联系人表ID(收货信息)
  121. "type": "", //订单类型
  122. "typemx": "", //明细分类,可选
  123. "remarks": "", //可选
  124. "saler_hrid":0,//销售人员hrid,业务员hrid
  125. "tradefield":"",//必选
  126. "pay_enterpriseid": 0, //结算单位
  127. "rebate_used":0,//默认0,是否使用返利金
  128. "billdate":"",//单据日期,默认创建日期
  129. "signbacknum":"",
  130. "contractname":'',
  131. "projectnote":""
  132. },
  133. rules: {
  134. sa_brandid: [{
  135. required: true,
  136. message: '请选择选择品牌',
  137. trigger: 'change'
  138. }],
  139. tradefield: [{
  140. required: true,
  141. message: '请选择选择领域',
  142. trigger: 'change'
  143. }],
  144. sys_enterpriseid:[{
  145. required: true,
  146. message: '订货企业不能为空',
  147. trigger: 'blur'
  148. }],
  149. contractname:[{
  150. required: true,
  151. message: '项目不能为空',
  152. trigger: 'blur'
  153. }],
  154. },
  155. sa_brandidOptions: [],
  156. tradefieldOptions: [],
  157. typemxlist:[]
  158. }
  159. },
  160. components:{
  161. enterprise,
  162. orderCanUseContract,
  163. orderCanUseActivity
  164. },
  165. methods:{
  166. async handleCommand (command) {
  167. this.form.type = command
  168. if (this.form.type == '特殊订单') {
  169. this.rules.typemx = [{
  170. required: true,
  171. message: '请选择选子分类',
  172. trigger: 'change'
  173. }]
  174. } else {
  175. delete this.rules.typemx
  176. }
  177. if (command === '工具订单') {
  178. const res = await this.$api.requested({
  179. "id": 20221108111402,
  180. "content":this.form
  181. })
  182. this.tool.showMessage(res,()=>{
  183. this.$store.dispatch('changeDetailDrawer',true)
  184. this.$router.push({path:'/agent_orderDetails',query:{id:res.data.sa_orderid,rowindex:res.data.rowindex}})
  185. })
  186. } else {
  187. this.drawer = true
  188. this.pageData()
  189. this.specordermx()
  190. }
  191. },
  192. submitForm() {
  193. this.$refs['form'].validate(async valid => {
  194. if (!valid) return
  195. const res = await this.$api.requested({
  196. "id":this.form.type ==='项目订单'?20230103141402: 20221108111402,
  197. "content":this.form
  198. })
  199. this.tool.showMessage(res,()=>{
  200. this.drawer = false
  201. this.refresh()
  202. this.$store.dispatch('changeDetailDrawer',true)
  203. this.$router.push({path:'/agent_orderDetails',query:{id:res.data.sa_orderid,rowindex:res.data.rowindex}})
  204. })
  205. })
  206. },
  207. async specordermx () {
  208. const res = await this.$store.dispatch('optiontypeselect','specordermx')
  209. this.typemxlist = res.data
  210. },
  211. resetForm() {
  212. this.$refs['form'].resetFields()
  213. },
  214. async pageData () {
  215. const res = await this.$api.requested({
  216. "id": 20220924163702,
  217. "content": {
  218. "pageSize": 999,
  219. }
  220. })
  221. this.sa_brandidOptions = res.data
  222. const res1 = await this.$api.requested({
  223. "id": 20221223141802,
  224. "content": {
  225. "pageSize": 999,
  226. }
  227. })
  228. this.tradefieldOptions = res1.data
  229. },
  230. rowClick (row) {
  231. this.form.sys_enterpriseid = row.sys_enterpriseid
  232. },
  233. contractClick (row) {
  234. console.log(row,'row')
  235. this.form.sa_contractid = row.sa_contractid
  236. this.form.sa_projectid = row.sa_projectid
  237. this.form.contractname = row.title === ''?'未知':row.title
  238. this.visible = false
  239. this.$refs['form'].validateField('contractname')
  240. },
  241. activityClick (row) {
  242. this.form.sa_promotionid = row.sa_promotionid
  243. this.form.promname = row.promname
  244. this.form.tradefield = row.tradefield
  245. this.form.sa_brandid = row.sa_brandid
  246. if (row.tradefield) {
  247. let arr = []
  248. arr = this.tradefieldOptions.filter(e=>{
  249. if (e.tradefield === row.tradefield) {
  250. return e
  251. }
  252. })
  253. this.childField = arr[0].subvalues
  254. }
  255. this.$refs['form'].validate()
  256. this.visible1 = false
  257. },
  258. refresh () {
  259. this.form = {
  260. "sa_orderid": 0,
  261. "sa_accountclassid": 0, //营销账户类型ID
  262. "sa_brandid": "", //品牌ID
  263. "sa_contractid": 0, //合同ID,标准订单不传
  264. "sa_projectid": 0, //工程项目表ID,标准订单不传
  265. "sys_enterprise_financeid": 0, //合作企业财务信息ID(开票信息)
  266. "sa_logiscompid": 0, //物流公司档案ID
  267. "rec_contactsid": 0, //合作企业联系人表ID(收货信息)
  268. "type": "", //订单类型
  269. "typemx": "", //明细分类,可选
  270. "remarks": "", //可选
  271. "saler_hrid":0,//销售人员hrid,业务员hrid
  272. "tradefield":"",//必选
  273. "pay_enterpriseid": 0, //结算单位
  274. "rebate_used":0,//默认0,是否使用返利金
  275. "billdate":"",//单据日期,默认创建日期
  276. "signbacknum":"",
  277. "contractname":'',
  278. "projectnote":""
  279. }
  280. this.visible1 = false
  281. }
  282. }
  283. }
  284. </script>
  285. <style>
  286. </style>