add.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <div>
  3. <el-button type="primary" size="small" @click="handleCommand">新 建</el-button>
  4. <el-dialog
  5. title="新建借用单"
  6. :visible.sync="drawer"
  7. direction="rtl"
  8. :show-close="false"
  9. append-to-body
  10. width="400px"
  11. @close="refresh">
  12. <div>
  13. <el-row :gutter="15">
  14. <el-form size="small" ref="form" :model="form" :rules="rules" label-width="100px" :status-icon="false">
  15. <el-col :span="24">
  16. <el-form-item label="企业信息" prop="sys_enterpriseid">
  17. <enterprise @rowClick="rowClick"></enterprise>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="24">
  21. <el-form-item label="借用方式">
  22. <el-radio-group v-model="radio">
  23. <el-radio :label="3">按合同约定借用</el-radio>
  24. <el-radio :label="6">单个借用</el-radio>
  25. </el-radio-group>
  26. </el-form-item>
  27. </el-col>
  28. <el-col v-if="radio === 3" :span="24">
  29. <el-form-item label="工具合同">
  30. <el-popover
  31. placement="bottom"
  32. trigger="click"
  33. v-model="visible">
  34. <toolCanUseContract ref="contract" @rowClick="contractClick"></toolCanUseContract>
  35. <el-input readonly v-model="form.contractname" slot="reference" placeholder="选择合同"></el-input>
  36. </el-popover>
  37. </el-form-item>
  38. </el-col>
  39. </el-form>
  40. </el-row>
  41. </div>
  42. <span slot="footer" class="dialog-footer">
  43. <el-button type="primary" size="small" @click="submitForm">创 建</el-button>
  44. <el-button size="small" @click="refresh">取 消</el-button>
  45. </span>
  46. </el-dialog>
  47. </div>
  48. </template>
  49. <script>
  50. import enterprise from '@/template/enterprise/index.vue'
  51. import toolCanUseContract from '@/template/toolBorrowingCanUseContract/index.vue'
  52. export default {
  53. data () {
  54. return {
  55. drawer:false,
  56. visible:false,
  57. visible1:false,
  58. radio:3,
  59. form:{
  60. "sa_orderid": 0,
  61. "sys_enterpriseid": 0, //订货企业id,可不传,默认取当前账号的
  62. "sa_accountclassid": 0, //营销账户类型ID
  63. "sa_brandid": "", //品牌ID
  64. "sa_contractid": null, //合同ID,标准订单不传
  65. "sa_projectid": 0, //工程项目表ID,标准订单不传
  66. "sys_enterprise_financeid": 0, //合作企业财务信息ID(开票信息)
  67. "sa_logiscompid": 0, //物流公司档案ID
  68. "rec_contactsid": 0, //合作企业联系人表ID(收货信息)
  69. "type": "", //订单类型
  70. "typemx": "", //明细分类,可选
  71. "remarks": "", //可选
  72. "tradefield":"",//必选
  73. "pay_enterpriseid": 0, //结算单位
  74. "rebate_used":0,//默认0,是否使用返利金
  75. "billdate":"",//单据日期,默认创建日期
  76. "signbacknum":"",
  77. "promname":""
  78. },
  79. rules: {
  80. sa_brandid: [{
  81. required: true,
  82. message: '请选择选择品牌',
  83. trigger: 'change'
  84. }],
  85. tradefield: [{
  86. required: true,
  87. message: '请选择选择领域',
  88. trigger: 'change'
  89. }],
  90. typemx: [{
  91. required: true,
  92. message: '请选择选子分类',
  93. trigger: 'change'
  94. }],
  95. sys_enterpriseid:[{
  96. required: true,
  97. message: '订货企业不能为空',
  98. trigger: 'blur'
  99. }],
  100. promname:[{
  101. required: true,
  102. message: '活动不能为空',
  103. trigger: 'blur'
  104. }],
  105. },
  106. sa_brandidOptions: [],
  107. tradefieldOptions: [],
  108. typemxlist:[],
  109. childField:[]
  110. }
  111. },
  112. components:{
  113. enterprise,
  114. toolCanUseContract
  115. },
  116. methods:{
  117. handleCommand (command) {
  118. this.drawer = true
  119. this.pageData()
  120. this.specordermx()
  121. this.$nextTick(()=>{
  122. this.$refs['contract'].listData()
  123. })
  124. },
  125. submitForm() {
  126. this.$refs['form'].validate(async valid => {
  127. if (!valid) return
  128. const res = await this.$api.requested({
  129. "id": 20230116092702,
  130. "content":this.form
  131. })
  132. this.tool.showMessage(res,()=>{
  133. if (this.form.sa_contractid) {
  134. this.addContractTool(res.data.sa_orderid)
  135. }
  136. this.drawer = false
  137. this.$store.dispatch('changeDetailDrawer',true)
  138. this.$router.push({path:'/toolBorrowingMagDetail',query:{id:res.data.sa_orderid,rowindex:res.data.rowindex}})
  139. })
  140. })
  141. },
  142. async addContractTool (sa_orderid) {
  143. const res = await this.$api.requested({
  144. "id": 20230116142602,
  145. "content": {
  146. "sa_orderid":sa_orderid,
  147. "sys_enterpriseid": this.form.sys_enterpriseid,
  148. "sa_contractid":this.form.sa_contractid
  149. },
  150. })
  151. },
  152. async specordermx () {
  153. const res = await this.$store.dispatch('optiontypeselect','specordermx')
  154. this.typemxlist = res.data
  155. },
  156. resetForm() {
  157. this.$refs['form'].resetFields()
  158. },
  159. async pageData () {
  160. const res = await this.$api.requested({
  161. "id": 20220924163702,
  162. "content": {
  163. "pageSize": 999,
  164. }
  165. })
  166. this.sa_brandidOptions = res.data
  167. const res1 = await this.$api.requested({
  168. "id": 20221223141802,
  169. "content": {
  170. "pageSize": 999,
  171. }
  172. })
  173. this.tradefieldOptions = res1.data
  174. },
  175. rowClick (row) {
  176. this.form.sys_enterpriseid = row.sys_enterpriseid
  177. this.$refs['contract'].listData(row.sys_enterpriseid)
  178. },
  179. contractClick (row) {
  180. this.form.sa_contractid = row.sa_contractid
  181. this.form.sa_projectid = row.sa_projectid
  182. this.form.contractname = row.title === ''?'未知':row.title
  183. this.visible = false
  184. },
  185. setChildField (item) {
  186. this.childField = item.subvalues
  187. },
  188. refresh () {
  189. this.form = {
  190. "sa_orderid": 0,
  191. "sys_enterpriseid": 0, //订货企业id,可不传,默认取当前账号的
  192. "sa_accountclassid": 0, //营销账户类型ID
  193. "sa_brandid": "", //品牌ID
  194. "sa_contractid": 0, //合同ID,标准订单不传
  195. "sa_projectid": 0, //工程项目表ID,标准订单不传
  196. "sys_enterprise_financeid": 0, //合作企业财务信息ID(开票信息)
  197. "sa_logiscompid": 0, //物流公司档案ID
  198. "rec_contactsid": 0, //合作企业联系人表ID(收货信息)
  199. "type": "", //订单类型
  200. "typemx": "", //明细分类,可选
  201. "remarks": "", //可选
  202. "saler_hrid":0,//销售人员hrid,业务员hrid
  203. "tradefield":"",//必选
  204. "pay_enterpriseid": 0, //结算单位
  205. "rebate_used":0,//默认0,是否使用返利金
  206. "billdate":"",//单据日期,默认创建日期
  207. "signbacknum":""
  208. }
  209. this.$refs['enterprise'].form.enterprisename = ''
  210. this.drawer = false
  211. }
  212. }
  213. }
  214. </script>
  215. <style>
  216. </style>